Environment configuration
Here is a simple way to configure the environment. Note that you must install in an empty new environment to avoid library version conflicts. First install tensorflow successfully and then install other libraries.
install anaconda
Configuration Environment
Open Anaconda Prompt
to create a new environment
conda create --name tf2 python=3.8
View all environments, then you should see two environments, one base and one tf2.
There will be a * in front of base, indicating that the base environment is currently used.
conda info --envs
Switch to the tf2 environment
conda activate tf2
If there is no n card, then only tensorflow cpu version can be installed
pip install tensorflow
If there is n card
conda install cudatoolkit=11.3.1
conda install cudnn=8.2.1
pip install tensorflow-gpu
After the installation is successful, create a new py file or jupyter notebook to test whether the gpu is available
import tensorflow as tf
print(tf.test.is_gpu_available())
Finally, install other required libraries, such as opencv, matplotlib, etc. Install whatever you need, you don’t need to deliberately install everything in one step.
google colab
If it is really difficult to configure the environment, or there is no graphics card, Google's colab is recommended here. Colab can use tensorflow directly without configuring the environment, which is very convenient. The downside is that magic is required.
With tensorflow, there is no need to configure the environment, which is very convenient. The downside is that magic is required.
The jupyter notebook file is also provided here, which can be directly uploaded to colab for use, but the data set needs to be uploaded to Google cloud disk synchronously and the path modified.