创建根目录
mkdir project_dircd project_dir
安装tensorflow=2.6
创建conda环境,python=3.8
conda create -n deeplab python=3.8conda activate deeplab#首先查看gcc版本是否符合要求# https://www.tensorflow.org/install/source#tested_build_configurationsgcc --versionnvcc -V#安装tensorflow环境pip install -i https://mirror.baidu.com/pypi/simple tensorflow==2.6# 安装CUDAconda install cudatoolkit=11.3 #11.2报错,找不到(原因是本地版本的问题)# 安装Cudnnconda install cudnn=8.2 # 8.1报错#测试tf是否可用import tensorflow as tfimport osos.environ['TF_CPP_MIN_LOG_LEVEL']='2'a = tf.constant(1.)b = tf.constant(2.)print(a+b)print('GPU:', tf.test.is_gpu_available())上诉查看GPU是否可以的方法在2.6后即将被遗弃,使用tf.config.list_physical_devices('GPU')# 后面会有一个坑。keras版本与tensorflow版本不匹配,pip install -i https://mirror.baidu.com/pypi/simple keras==2.6

- 安装protobuf
sudo apt-get install protobuf-compiler
Alternatively, you can also download the package from web on other platforms. Please refer to https://github.com/protocolbuffers/protobuf for more details about installation.
other libraries
pip install -i https://mirror.baidu.com/pypi/simple pillowpip install -i https://mirror.baidu.com/pypi/simple matplotlibpip install -i https://mirror.baidu.com/pypi/simple cythonpip install -i https://mirror.baidu.com/pypi/simple pycocotools
安装 Orbit
Orbit is a flexible, lightweight library designed to make it easy to write custom training loops in TensorFlow 2. We used Orbit in our train/eval loops. You need to download the code below:
cd project_dirgit clone https://github.com/tensorflow/models.git
- 安装pycocotools
We also use pycocotools for instance segmentation evaluation. Below is the installation guide:
cd project_dirgit clone https://github.com/cocodataset/cocoapi.git# Compile cocoapicd project_dir/cocoapi/PythonAPImakecd project_dir
- 编译Compilation
- 添加环境变量
```python
cd project_dir
deeplab2
export PYTHONPATH=$PYTHONPATH:pwdorbit
export PYTHONPATH=$PYTHONPATH:${PATH_TO_MODELS}pycocotools
export PYTHONPATH=$PYTHONPATH:${PATH_TO_cocoapi_PythonAPI}三者在同一根目录下,可按如下配置
export PYTHONPATH=$PYTHONPATH:pwd:pwd/models:pwd/cocoapi/PythonAPI
这个是临时的,需要在.bashrc 文件中添加永久的环境变量。- 编译protocol Buffers```python# `${PATH_TO_PROTOC}` is the directory where the `protoc` binary locates.${PATH_TO_PROTOC} deeplab2/*.proto --python_out=.# Alternatively, if protobuf compiler is globally accessible, you can simply run:protoc deeplab2/*.proto --python_out=.
- 测试配置—先重启
You can test if you have successfully installed and configured DeepLab2 by running the following commands (requires compilation of custom ops这一步省略了):
# Model training test (test for custom ops, protobuf)python deeplab2/model/deeplab_test.py# Model evaluator test (test for other packages such as orbit, cocoapi, etc)python deeplab2/trainer/evaluator_test.py
也可以在pycharm中测试
