Skip to content

Commit 27ba8a4

Browse files
Merge pull request tensorflow#2299 from sgkouzias:patch-1
PiperOrigin-RevId: 671419272
2 parents 69a53ae + 06798ba commit 27ba8a4

File tree

1 file changed

+52
-3
lines changed

1 file changed

+52
-3
lines changed

site/en/install/pip.md

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,25 @@ The following NVIDIA® software are only required for GPU support.
194194
nvidia-smi
195195
```
196196

197-
### 3. Install TensorFlow
197+
### 3. Create a virtual environment with [venv](https://docs.python.org/3/library/venv.html){:.external}
198+
199+
The venv module is part of Python’s standard library and is the officially recommended way to create virtual environments.
200+
201+
Navigate to your desired virtual environments directory and create a new venv environment named `tf` with the following command.
202+
203+
```bash
204+
python3 -m venv tf
205+
```
206+
207+
You can activate it with the following command.
208+
209+
```bash
210+
source tf/bin/activate
211+
```
212+
213+
Make sure that the virtual environment is activated for the rest of the installation.
214+
215+
### 4. Install TensorFlow
198216

199217
TensorFlow requires a recent version of pip, so upgrade your pip
200218
installation to be sure you're running the latest version.
@@ -212,7 +230,9 @@ The following NVIDIA® software are only required for GPU support.
212230
pip install tensorflow
213231
```
214232
215-
### 4. Verify the installation
233+
**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.
234+
235+
### 6. Verify the installation
216236
217237
Verify the CPU setup:
218238
@@ -229,7 +249,36 @@ The following NVIDIA® software are only required for GPU support.
229249
```
230250

231251
If a list of GPU devices is returned, you've installed TensorFlow
232-
successfully.
252+
successfully. **If not continue to the next step**.
253+
254+
### 6. [GPU only] Virtual environment configuration
255+
256+
If the GPU test in the last section was unsuccessful, the most likely cause is that components aren't being detected,
257+
and/or conflict with the existing system CUDA installation. So you need to add some symbolic links to fix this.
258+
259+
* Create symbolic links to NVIDIA shared libraries:
260+
261+
```bash
262+
pushd $(dirname $(python -c 'print(__import__("tensorflow").__file__)'))
263+
ln -svf ../nvidia/*/lib/*.so* .
264+
popd
265+
```
266+
267+
* Create a symbolic link to ptxas:
268+
269+
```bash
270+
ln -sf $(find $(dirname $(dirname $(python -c "import nvidia.cuda_nvcc;
271+
print(nvidia.cuda_nvcc.__file__)"))/*/bin/) -name ptxas -print -quit) $VIRTUAL_ENV/bin/ptxas
272+
```
273+
274+
Verify the GPU setup:
275+
276+
```bash
277+
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
278+
```
279+
280+
281+
233282

234283
* {MacOS}
235284

0 commit comments

Comments
 (0)