Skip to content

Commit b81e4f2

Browse files
authored
Update pip.md
Rename environment variable to PTXAS_DIR and package manager options.
1 parent 82713bf commit b81e4f2

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

site/en/install/pip.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ The following NVIDIA® software are only required for GPU support.
195195

196196
### 3. Install Miniconda
197197

198-
You can skip this section if you prefer to use Python’s built in venv module instead of Miniconda.
198+
You can skip this section if you have already installed `Miniconda` (referred as *option #1* in the next steps) or you prefer to use Python’s built-in `venv` module (referred as *option #2* in the next steps) instead.
199199

200200
[Miniconda](https://docs.conda.io/en/latest/miniconda.html){:.external}
201201
is the recommended approach for installing TensorFlow with GPU support.
@@ -208,7 +208,7 @@ The following NVIDIA® software are only required for GPU support.
208208

209209
### 4. Create a virtual environment
210210

211-
#### First option: Miniconda
211+
* ***Option #1: Miniconda***
212212

213213
Create a new conda environment named `tf` with the following command.
214214

@@ -222,9 +222,11 @@ The following NVIDIA® software are only required for GPU support.
222222
conda deactivate
223223
```
224224

225-
#### Second option: [venv](https://docs.python.org/3/library/venv.html){:.external}
226-
227-
Navigate to your desired virtual environments' directory and create a new venv environment named `tf` with the following command.
225+
* ***Option #2: venv***
226+
227+
The [venv](https://docs.python.org/3/library/venv.html){:.external} module supports creating lightweight “virtual environments”, each with their own independent set of Python packages installed in their site directories.
228+
229+
Navigate to your desired virtual environments directory and create a new venv environment named `tf` with the following command.
228230

229231
```bash
230232
python3 -m venv tf
@@ -261,7 +263,7 @@ The following NVIDIA® software are only required for GPU support.
261263
262264
You can skip this section if you only run TensorFlow on the CPU.
263265
264-
#### First option: Miniconda
266+
* ***Option #1: Miniconda***
265267
266268
Locate the directory for the conda environment in your terminal window by running in the terminal:
267269
`echo $CONDA_PREFIX`
@@ -289,11 +291,11 @@ The following NVIDIA® software are only required for GPU support.
289291
# Set LD_LIBRARY_PATH to include CUDNN directory
290292
export LD_LIBRARY_PATH=$(find ${CUDNN_DIR}/*/lib/ -type d -printf "%p:")${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
291293
292-
# Get the directory of NVCC binaries
293-
NVCC_DIR=$(dirname $(dirname $(python -c "import nvidia.cuda_nvcc; print(nvidia.cuda_nvcc.__file__)")))
294+
# Get the ptxas directory
295+
PTXAS_DIR=$(dirname $(dirname $(python -c "import nvidia.cuda_nvcc; print(nvidia.cuda_nvcc.__file__)")))
294296
295-
# Set PATH to include all directories containing NVCC binaries
296-
export PATH=$(find ${NVCC_DIR}/*/bin/ -type d -printf "%p:")${PATH:+:${PATH}}
297+
# Set PATH to include the directory containing ptxas
298+
export PATH=$(find ${PTXAS_DIR}/*/bin/ -type d -printf "%p:")${PATH:+:${PATH}}
297299
```
298300
Edit `./etc/conda/deactivate.d/env_vars.sh` as follows:
299301
@@ -305,9 +307,9 @@ The following NVIDIA® software are only required for GPU support.
305307
306308
# Unset environment variables
307309
unset CUDNN_DIR
308-
unset NVCC_DIR
310+
unset PTXAS_DIR
309311
```
310-
#### Second option: venv
312+
* ***Option #2: venv***
311313
312314
Locate the directory for the venv environment in your terminal window by running in the terminal:
313315
`echo $VIRTUAL_ENV`
@@ -324,22 +326,22 @@ The following NVIDIA® software are only required for GPU support.
324326
# Set LD_LIBRARY_PATH to include CUDNN directory
325327
export LD_LIBRARY_PATH=$(find ${CUDNN_DIR}/*/lib/ -type d -printf "%p:")${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
326328
327-
# Get the directory of NVCC binaries
328-
NVCC_DIR=$(dirname $(dirname $(python -c "import nvidia.cuda_nvcc; print(nvidia.cuda_nvcc.__file__)")))
329+
# Get the ptxas directory
330+
PTXAS_DIR=$(dirname $(dirname $(python -c "import nvidia.cuda_nvcc; print(nvidia.cuda_nvcc.__file__)")))
329331
330-
# Set PATH to include all directories containing NVCC binaries
331-
export PATH=$(find ${NVCC_DIR}/*/bin/ -type d -printf "%p:")${PATH:+:${PATH}}
332+
# Set PATH to include the directory containing ptxas
333+
export PATH=$(find ${PTXAS_DIR}/*/bin/ -type d -printf "%p:")${PATH:+:${PATH}}
332334
```
333335
334336
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:
335337
336338
```bash
337339
deactivate () {
338340
# ...
339-
# Unset the added path to PATH if within a virtual environment
341+
# Unset the added path to PATH if within the virtual environment
340342
if [ -n "$VIRTUAL_ENV" ]; then
341343
# Remove the path from PATH
342-
PATH=$(echo $PATH | sed -e "s|${NVCC_DIR}/*/bin/:||g")
344+
PATH=$(echo $PATH | sed -e "s|${PTXAS_DIR}/*/bin/:||g")
343345
fi
344346
345347
# Restore original LD_LIBRARY_PATH
@@ -350,7 +352,7 @@ The following NVIDIA® software are only required for GPU support.
350352
351353
# Unset environment variables
352354
unset CUDNN_DIR
353-
unset NVCC_DIR
355+
unset PTXAS_DIR
354356
}
355357
```
356358

0 commit comments

Comments
 (0)