Configuring a tensorflow environment to work with gpu's is really annoying. Thankfully, conda & pipmake it a lot less annoying.
Here are the core dependencies for getting this to work.
- cudatoolkit=11.6.0
- cudnn=8.2.1.32
- tensorflow=2.7.0
- tensorflow-gpu=2.7.0
- tensorflow-io=0.25.0
- python=3.9
- keras=2.7.0
You could probably try to install each of these individually, but you might run into some issues. Give it a shot or follow how I did it below.
Update your nvidia drivers to the latest version. You can check your driver version by using the nvidia-smi
command and looking at the top. Here is my current setup: Driver Version: 510.60.02 CUDA Version: 11.6
- Install miniconda
- Create a conda environment with tensorflow-gpu support.
conda create --name tensorflow-27 tensorflow-gpu
This should create an environment which has almost all of the right dependencies, but the wrong versions.
Use the conda list
command to see what packages you have installed.
- Install tensorflow 2.7.0 with
pip install tensorflow==2.7.0
- Install/upgrade tensorflow-io with
pip install tensorflow-io=0.25.0
- Install tensorflow-gpu with conda-forge
conda install -c conda-forge tensorflow-gpu=2.7.0
(this will ask to change a bunch of packages around, accept it.) - Should be good to go! Install the tensorflow Object Detection API
- Verify the install by running
python object_detection/builders/model_builder_tf2_test.py
- Point Python to Object Detection API
export PYTHONPATH=$PYTHONPATH:/home/da/Documents/git-repos/models