Document description: This article is based on [ Official Documents In light of its own practice, there has been a slight reduction in the common installation steps (mainly due to the official consideration of various installation environments, this article is mainly limited to Ubuntu 16.04).
system requirements
- Python 3.5-3.7;
- pip 19.0 or higher (manylinux2010 support required);
- Ubuntu 16.04 or higher (64 bit)/ Windows 7 or higher (64 bit) (Python 3 only supported);
- GPU support requires a graphics card (for Ubuntu and Windows) that supports CUDA+, a Tensorflow2 NVIDIA+ GPU driver that requires 418.x or later, a CUDA version 10.1 and a cuDNN SDK (7.6 and higher) for TensorFlow 2.1.0 and higher;
- TensorRT 6.0 [Optional]: This module reduces latencies inferred from some models and improves throughput.
hardware requirements
- To use a GPU, you need to install a NVIDIA?? GPU card with CUDA?? computing power of 3.5 or higher;
- NVIDIA? GPU driver: CUDA 10.1 requires 418.x or higher.
Install GPU drivers and CUDA \cuDNN \TensorRT
Install via apt:
- The installation steps for Ubuntu version 16.04 are as follows:
# Add NVIDIA package repositories # Add HTTPS support for apt-keyruxia sudo apt-get install gnupg-curl wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_10.1.243-1_amd64.deb sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub sudo dpkg -i cuda-repo-ubuntu1604_10.1.243-1_amd64.deb sudo apt-get update wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu16ruxia04/x86_64/nvidia-machine-learning-repo-ubuntu1604_1.0.0-1_amd64.deb sudo apt install ./nvidia-machine-learning-repo-ubuntu1604_1.0.0-1_amd64.deb sudo apt-get update # Install NVIDIA driver # Issue with driver install requires creating /usr/lib/nvidia sudo mkdir /usr/lib/nvidia sudo apt-get install --no-install-recommends nvidia-418 # Reboot. Check that GPUs are visible using the command: nvidia-smi # Install development and runtime libraries (~4GB) sudo apt-get install --no-install-recommends cuda-10-1 libcudnn7=7.6.4.38-1+cuda10.1 libcudnn7-dev=7.6.4.38-1+cuda10.1 # Install TensorRT. Requires that libcudnn7 is installed above. sudo apt-get install -y --no-install-recommends libnvinfer6=6.0.1-1+cuda10.1 libnvinfer-dev=6.0.1-1+cuda10.1 libnvinfer-plugin6=6.0.1-1+cuda10.1
- The installation steps for Ubuntu 18.04 are as follows:
# Add NVIDIA package repositories wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.1.243-1_amd64.deb sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub sudo dpkg -i cuda-repo-ubuntu1804_10.1.243-1_amd64.deb sudo apt-get update wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb sudo apt install ./nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb sudo apt-get update # Install NVIDIA driver sudo apt-get install --no-install-recommends nvidia-driver-430 # Reboot. Check that GPUs are visible using the command: nvidia-smi # Install development and runtime libraries (~4GB) sudo apt-get install --no-install-recommends \ cuda-10-1 \ libcudnn7=7.6.4.38-1+cuda10.1 \ libcudnn7-dev=7.6.4.38-1+cuda10.1 # Install TensorRT. Requires that libcudnn7 is installed above. sudo apt-get install -y --no-install-recommends libnvinfer6=6.0.1-1+cuda10.1 \ libnvinfer-dev=6.0.1-1+cuda10.1 \ libnvinfer-plugin6=6.0.1-1+cuda10.1
Install Tensorflow 2
Anaconda needs to be installed from here Download the corresponding version.
The specific installation steps will not be redundant, just confirm all the way.
Create a virtual environment, below the "tensorflow2venv" is the name of the virtual environment, you can name it according to your situation.
# Create virtual environment tensorflow2venv conda create -n tensorflow2venv pip python=3.7 # select python version # Enter virtual environment conda activate tensorflow2venv # Update pip to the latest version python -m pip install --upgrade pip # Install the developed version of tensorflow2, if no version is specified, the latest version will be installed pip install tensorflow==2.1.0 # Test if tensorflow2 was installed successfully python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
If the output of the execution script ends up with text like "Created TensorFlow device", then the Tensorflow2 installation is complete and we can begin our in-depth learning journey.I wish you all the best.