New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Install tensorflow-gpu with conda #21
Comments
Hi @liganega, According to the official step-by-step installation guide with pip and conda, it should be sufficient to install First, make sure you have already installed Nvidia driver ( dependencies:
- cudatoolkit=11.2
- cudnn=8.1.0
- tensorflow=2.8 and follow the instructions from Please let me know if it works, because I'll be able to check it on my Ubuntu machine with GPU only in two days or so. |
Hi @vi3itor, thank you very much for your quick answer. I followed your instruction and the installation worked well without any problems, except that some packages were reinstalled with different versions when the pip dependences was handled, e.g., tf 2.8.2 was installed after 2.8 had been removed. However, the gpu support does not work although import tf works. And I am thinking why. First, I am using WSL2(Ubuntu 20.4) on Windows 11. And the command nvidia-smi shows the following: And the CUDA version is 11.6. Could it be the reason why gpu support doesn't work? Is it compatible with cudatoolkit=11.2 and cudnn=8.1.0? I am quite sure that gpu support should work because it worked when tf. 2.4 was installed by
|
Hi @liganega, Sorry, I assumed that you're on Linux. I have a Windows 10 with Titan Xp to test the setup, so next I'll list the required steps. The official guide by Nvidia describes how to set up WSL support, but TensorFlow's guide recommends doing it under the Windows native prompt. Here are the necessary steps:
@@ -1,9 +1,11 @@
name: homl3
channels:
- conda-forge
- - defaults
+ # - defaults
dependencies:
- box2d-py # used only in chapter 18, exercise 8
+ - cudatoolkit=11.2 # tensorflow dependencies for the GPU support
+ - cudnn=8.1.0 # tensorflow dependencies for the GPU support
- ftfy=5.5 # used only in chapter 16 by the transformers library
- graphviz # used only in chapter 6 for dot files
- python-graphviz # used only in chapter 6 for dot files
@@ -37,7 +39,7 @@ dependencies:
- tensorflow-addons~=0.16.1 # used in chapters 11 & 16 (for AdamW & seq2seq)
- tensorflow-datasets~=4.5.2 # datasets repository, ready to use
- tensorflow-hub~=0.12.0 # trained ML models repository, ready to use
- - tensorflow-serving-api~=2.8.0 # or tensorflow-serving-api-gpu if gpu
+ - tensorflow-serving-api~=2.8.0 # used only in chapter 19
- tensorflow~=2.8.0 # Deep Learning library
- transformers~=4.16.2 # Natural Language Processing lib for TF or PyTorch
- urlextract~=1.5.0 # optionally used in chapter 3, exercise 4
conda update -y -n base conda
conda env create -f environment.yml # or environment-gpu.yml if you downloaded the file from my repo
conda activate homl3
python -m ipykernel install --user --name=python3
jupyter notebook That's it. I tested GPU support on my Windows machine and everything works. Let me know if you have any problems and I'll prepare the PR. |
By the way, I forgot to mention that installing |
Hi @vi3itor, first I have not tried yet what you proposed. There are two reasons.
Here are the steps I took.
However tf-gpu didn't work, and I got the following message:
But then I encountered an answer from It suggests the following steps for repair:
Then tf-gpu suddenly works! To be honest, I don't know why it works. There should be some unnecessary steps. Probably you know more and why it helped. A last thing. A warning pops up with respect to NUMA support when one asks whether gpu support is there using the command
But people say it can be safely ignored. I just hope it is really so. |
Hi @liganega, I'm glad you figured out how to get it running inside the WSL 2 Ubuntu distro. My instructions above are the easiest I can think of for Windows users (and they are closely following official TensorFlow's instructions) to avoid all the hustles of installing the correct version of CUDA toolkit (without overwriting a special WSL Nvidia driver), updating LD_LIBRARY_PATH, etc. sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /" while following the guide from Nvidia earlier you had to use a special sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/ /" When updating packages in the future with I decided to try setting up the # download and install Miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
sh Miniconda3-latest-Linux-x86_64.sh
# restart bash to apply changes
source .bashrc
# update conda
conda update -y -n base conda
# checkout the repository with environment-gpu.yml
git clone https://github.com/vi3itor/handson-ml3.git && cd handson-ml3 && git checkout -b windows-gpu && git pull origin windows-gpu
# create homl3 environment
conda env create -f environment-gpu.yml
conda activate homl3
python3 -m ipykernel install --user --name=python3 When I tried W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
...
Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. But export LD_LIBRARY_PATH=/home/$USER/miniconda3/envs/homl3/lib/:$LD_LIBRARY_PATH Now ...
I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:922] could not open file to read NUMA node: /sys/bus/pci/devices/0000:01:00.0/numa_node
Your kernel may have been built without NUMA support.
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')] More importantly, when I run As you can see, the support of WSL is still experimental, and it might be much easier to run the notebooks natively on Windows. I'll edit the instructions above to remove the requirement to install WSL 2 because it's not needed in this case. And I'd like to ask you to try these steps to see if it works well on Windows 11 with RTX video card. You can also compare how much time it takes to run |
Dear @vi3itor, I really appreciate your dedication, thank you so much for that. Your instruction how to create conda environment for tensorflow gpu support on Windows 10/11 worked perfectly. It is the easiest way I know. Let me summarize again:
PS. I didn't try any more to struggle with WSL. Your solution is just perfect for me. |
Thank you too! I also would like to know an easy way on top of WSL under Windows 10/11. Recently I tried again that way following CUDA on WSL User Guide, but failed.
Using docker images could be a solution, but don't know yet. |
The following sentence from "INSATALL.md" is somewhat outdated:
It is because the official command below uses tf version 2.4 which is not compatible with the jupyter notebooks for homl3.
Cf. https://anaconda.org/anaconda/tensorflow-gpu
Is there any other easy way to use tensorflow-gpu?
The text was updated successfully, but these errors were encountered: