Instalando o Tensorflow com suporte a GPU no Windows com WSL2

brunaguedes92

Bruna Guedes

Posted on April 17, 2024

Instalando o Tensorflow com suporte a GPU no Windows com WSL2

Depois de passar horas tentando resolver, lendo vários posts, vou resumir aqui o que certo pra mim.

Dado que: já tenho WSL2 instalado e tenho rtx 4070

1: Instalar os drivers no windows

baixar o driver: search e download - https://www.nvidia.com/drivers
baixar cuda toolkit https://developer.nvidia.com/cuda-downloads?target_os=Windows
baixar e instalar cudnn driver https://developer.nvidia.com/cudnn

obs: não instale nada pelo terminal do wsl, pode dar problema

2. Variáveis de ambiente!!! Muito importante

export PATH=/usr/local/cuda/bin:$PATH
CUDNN_PATH=$(dirname $(python -c "import nvidia.cudnn;print(nvidia.cudnn.file)"))
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/:$CUDNN_PATH/lib

3. instalar tensorflow

pip install tensorflow[and-cuda]

se estiver usando zsh

pip install "tensorflow[and-cuda]"

4. testar no terminal do ubuntu os comandos
nvidia-smi.exe

nvcc -V

python3 -c "import tensorflow as tf; print(len(tf.config.list_physical_devices('GPU')))"

5. Para tirar um warning

export TF_CPP_MIN_LOG_LEVEL=2

sudo apt-get install numactl
numactl --show

https://discuss.tensorflow.org/t/tensorflow-installation-error/15889/3
https://medium.com/@jessicaisri/instalando-o-tensorflow-com-suporte-a-gpu-no-windows-com-wsl2-2858f4df08e5

💖 💪 🙅 🚩
brunaguedes92
Bruna Guedes

Posted on April 17, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related