Skip to content

Commit 7cf1c57

Browse files
authored
Instructions to create symlinks to NVIDIA shared libraries and ptxas.
Replaced instructions to modify default activate/deactivate scripts with instructions to create symlinks to NVIDIA shared libraries and ptxas.
1 parent 146bbeb commit 7cf1c57

File tree

1 file changed

+8
-38
lines changed

1 file changed

+8
-38
lines changed

site/en/install/pip.md

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -232,53 +232,23 @@ The following NVIDIA® software are only required for GPU support.
232232
233233
Note: Do not install TensorFlow with `conda`. It may not have the latest stable version. `pip` is recommended since TensorFlow is only officially released to PyPI.
234234
235-
### 5. Set environment variables
235+
### 5. Virtual environment configuration
236236
237237
You can skip this section if you only run TensorFlow on the CPU.
238238
239-
Locate the directory for the venv environment in your terminal window by running in the terminal:
240-
`echo $VIRTUAL_ENV`
241-
242-
Enter that directory and add the following lines at the end of the activate script `./bin/activate` as follows:
239+
* Create symbolic links to NVIDIA shared libraries:
243240
244241
```bash
245-
# Store original LD_LIBRARY_PATH
246-
export ORIGINAL_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
247-
248-
# Get the CUDNN directory
249-
CUDNN_DIR=$(dirname $(dirname $(python -c "import nvidia.cudnn; print(nvidia.cudnn.__file__)")))
250-
251-
# Set LD_LIBRARY_PATH to include CUDNN directory
252-
export LD_LIBRARY_PATH=$(find ${CUDNN_DIR}/*/lib/ -type d -printf "%p:")${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
253-
254-
# Get the ptxas directory
255-
PTXAS_DIR=$(dirname $(dirname $(python -c "import nvidia.cuda_nvcc; print(nvidia.cuda_nvcc.__file__)")))
256-
257-
# Set PATH to include the directory containing ptxas
258-
export PATH=$(find ${PTXAS_DIR}/*/bin/ -type d -printf "%p:")${PATH:+:${PATH}}
242+
pushd $(dirname $(python -c 'print(__import__("tensorflow").__file__)'))
243+
ln -svf ../nvidia/*/lib/*.so* .
244+
popd
259245
```
260246
261-
Add the following lines at the end of `deactivate` block in the activate script to ensure that the necessary NVIDIA environment variables are set only while the virtual environment is active:
247+
* Create a symbolic link to ptxas:
262248
263249
```bash
264-
deactivate () {
265-
# ...
266-
# Unset the added path to PATH if within the virtual environment
267-
if [ -n "$VIRTUAL_ENV" ]; then
268-
# Remove the path from PATH
269-
PATH=$(echo $PATH | sed -e "s|${PTXAS_DIR}/*/bin/:||g")
270-
fi
271-
272-
# Restore original LD_LIBRARY_PATH
273-
if [ -n "$ORIGINAL_LD_LIBRARY_PATH" ]; then
274-
export LD_LIBRARY_PATH=$ORIGINAL_LD_LIBRARY_PATH
275-
unset ORIGINAL_LD_LIBRARY_PATH
276-
fi
277-
278-
# Unset environment variables
279-
unset CUDNN_DIR
280-
unset PTXAS_DIR
281-
}
250+
ln -sf $(find $(dirname $(dirname $(python -c "import nvidia.cuda_nvcc;
251+
print(nvidia.cuda_nvcc.__file__)"))/*/bin/) -name ptxas -print -quit) $VIRTUAL_ENV/bin/ptxas
282252
```
283253
284254
### 6. Verify the installation

0 commit comments

Comments
 (0)