|
| 1 | +# FFB6D环境配置指南:原生系统安装 |
| 2 | + |
| 3 | +## 1. 系统要求 |
| 4 | + |
| 5 | +- Ubuntu 20.04/22.04/24.04 |
| 6 | +- NVIDIA GPU(支持CUDA) |
| 7 | +- 至少8GB内存 |
| 8 | +- 至少30GB磁盘空间 |
| 9 | + |
| 10 | +## 2. 基础环境配置 |
| 11 | + |
| 12 | +### 2.1 安装NVIDIA驱动 |
| 13 | + |
| 14 | +```bash |
| 15 | +# 添加NVIDIA包仓库 |
| 16 | +sudo add-apt-repository ppa:graphics-drivers/ppa |
| 17 | +sudo apt-get update |
| 18 | + |
| 19 | +# 安装NVIDIA驱动 |
| 20 | +sudo apt-get install -y nvidia-driver-535 # 根据需要选择版本 |
| 21 | + |
| 22 | +# 重启系统 |
| 23 | +sudo reboot |
| 24 | + |
| 25 | +# 验证安装 |
| 26 | +nvidia-smi |
| 27 | +``` |
| 28 | + |
| 29 | +### 2.2 安装CUDA和cuDNN |
| 30 | + |
| 31 | +```bash |
| 32 | +# 下载并安装CUDA 11.0 |
| 33 | +wget https://developer.download.nvidia.com/compute/cuda/11.0.3/local_installers/cuda_11.0.3_450.51.06_linux.run |
| 34 | +sudo sh cuda_11.0.3_450.51.06_linux.run |
| 35 | + |
| 36 | +# 配置环境变量 |
| 37 | +echo 'export PATH=/usr/local/cuda-11.0/bin:$PATH' >> ~/.bashrc |
| 38 | +echo 'export LD_LIBRARY_PATH=/usr/local/cuda-11.0/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc |
| 39 | +source ~/.bashrc |
| 40 | + |
| 41 | +# 下载并安装cuDNN 8.0 |
| 42 | +# 注:需要从NVIDIA开发者网站下载cuDNN v8.0,解压后: |
| 43 | +sudo cp cuda/include/cudnn*.h /usr/local/cuda/include |
| 44 | +sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64 |
| 45 | +sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn* |
| 46 | +``` |
| 47 | + |
| 48 | +### 2.3 安装系统依赖 |
| 49 | + |
| 50 | +```bash |
| 51 | +sudo apt-get update |
| 52 | +sudo apt-get install -y \ |
| 53 | + python3.6 \ |
| 54 | + python3.6-dev \ |
| 55 | + python3-pip \ |
| 56 | + git \ |
| 57 | + cmake \ |
| 58 | + build-essential \ |
| 59 | + libopencv-dev \ |
| 60 | + libglib2.0-0 \ |
| 61 | + libsm6 \ |
| 62 | + libxext6 \ |
| 63 | + libxrender-dev \ |
| 64 | + libboost-all-dev \ |
| 65 | + libeigen3-dev |
| 66 | +``` |
| 67 | + |
| 68 | +### 2.4 配置Python环境 |
| 69 | + |
| 70 | +```bash |
| 71 | +# 设置Python 3.6为默认版本 |
| 72 | +sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 1 |
| 73 | +sudo update-alternatives --set python3 /usr/bin/python3.6 |
| 74 | + |
| 75 | +# 配置pip镜像源 |
| 76 | +pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple |
| 77 | + |
| 78 | +# 升级pip |
| 79 | +python3 -m pip install --upgrade pip |
| 80 | +``` |
| 81 | + |
| 82 | +## 3. 安装PyTorch和依赖包 |
| 83 | + |
| 84 | +### 3.1 安装PyTorch |
| 85 | + |
| 86 | +```bash |
| 87 | +pip3 install torch==1.10.2+cu113 torchvision==0.11.3+cu113 -f https://download.pytorch.org/whl/torch_stable.html |
| 88 | +``` |
| 89 | + |
| 90 | +### 3.2 安装项目依赖 |
| 91 | + |
| 92 | +创建requirements.txt并安装依赖: |
| 93 | + |
| 94 | +```bash |
| 95 | +pip3 install -r requirements.txt |
| 96 | +``` |
| 97 | + |
| 98 | +requirements.txt内容: |
| 99 | +``` |
| 100 | +h5py |
| 101 | +numpy |
| 102 | +pyyaml==5.4.1 |
| 103 | +enum34 |
| 104 | +future |
| 105 | +scipy==1.4.1 |
| 106 | +opencv_contrib_python==3.4.2.16 |
| 107 | +transforms3d==0.3.1 |
| 108 | +scikit_image==0.13.1 |
| 109 | +lmdb==0.94 |
| 110 | +setuptools==41.0.0 |
| 111 | +cffi==1.11.5 |
| 112 | +easydict==1.7 |
| 113 | +plyfile==0.6 |
| 114 | +pillow==8.2.0 |
| 115 | +dataclasses |
| 116 | +glumpy |
| 117 | +tqdm |
| 118 | +tensorboardX |
| 119 | +pandas |
| 120 | +scikit-learn |
| 121 | +scipy |
| 122 | +termcolor |
| 123 | +pybind11 |
| 124 | +``` |
| 125 | + |
| 126 | +## 4. 编译和安装特殊组件 |
| 127 | + |
| 128 | +### 4.1 编译apex |
| 129 | + |
| 130 | +```bash |
| 131 | +git clone https://github.com/NVIDIA/apex |
| 132 | +cd apex |
| 133 | +export TORCH_CUDA_ARCH_LIST="6.0;6.1;6.2;7.0;7.5" |
| 134 | +python setup.py install -v |
| 135 | +cd .. |
| 136 | +``` |
| 137 | + |
| 138 | +### 4.2 安装和编译normalspeed |
| 139 | + |
| 140 | +```bash |
| 141 | +# 1. 准备OpenCV环境 |
| 142 | +pip uninstall opencv-python opencv-python-headless -y |
| 143 | +pip install opencv-python==4.5.3.56 |
| 144 | + |
| 145 | +# 2. 克隆并安装normalspeed |
| 146 | +git clone https://github.com/hfutcgncas/normalspeed.git |
| 147 | +cd normalspeed/normalSpeed |
| 148 | + |
| 149 | +# 安装编译依赖 |
| 150 | +sudo apt-get install python3-pybind11 |
| 151 | +pip3 install Cython==0.29.15 |
| 152 | + |
| 153 | +# 清理并重新安装 |
| 154 | +rm -rf build/ dist/ *.egg-info/ |
| 155 | +python3 setup.py install --user |
| 156 | +cd ../.. |
| 157 | +``` |
| 158 | + |
| 159 | +## 5. 克隆和配置FFB6D |
| 160 | + |
| 161 | +```bash |
| 162 | +# 克隆代码 |
| 163 | +git clone https://github.com/ethnhe/FFB6D.git |
| 164 | +cd FFB6D |
| 165 | + |
| 166 | +# 创建必要的目录 |
| 167 | +mkdir -p datasets models train_log |
| 168 | + |
| 169 | +# 配置环境变量 |
| 170 | +export PYTHONPATH=$PYTHONPATH:$(pwd) |
| 171 | +``` |
| 172 | + |
| 173 | +## 6. 验证安装 |
| 174 | + |
| 175 | +```bash |
| 176 | +# 验证CUDA支持 |
| 177 | +python3 -c "import torch; print('CUDA available:', torch.cuda.is_available())" |
| 178 | + |
| 179 | +# 验证apex安装 |
| 180 | +python3 -c "from apex import amp; print('APEX installed')" |
| 181 | + |
| 182 | +# 验证normalspeed安装 |
| 183 | +python3 -c "import normalSpeed; print('normalspeed installed')" |
| 184 | +``` |
| 185 | + |
| 186 | +## 7. 常见问题 |
| 187 | + |
| 188 | +### 7.1 网络问题 |
| 189 | + |
| 190 | +```bash |
| 191 | +# 使用代理(如需要) |
| 192 | +export http_proxy="http://proxy:port" |
| 193 | +export https_proxy="http://proxy:port" |
| 194 | + |
| 195 | +# 或使用国内镜像源 |
| 196 | +pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple |
| 197 | +``` |
| 198 | + |
| 199 | +### 7.2 版本兼容性问题 |
| 200 | + |
| 201 | +- 确保NVIDIA驱动版本支持CUDA 11.0 |
| 202 | +- 确保Python包版本相互兼容 |
| 203 | +- 检查CUDA版本与PyTorch版本的匹配 |
| 204 | + |
| 205 | +### 7.3 编译错误 |
| 206 | + |
| 207 | +- 确保已安装所有必要的编译工具 |
| 208 | +- 检查CUDA路径配置是否正确 |
| 209 | +- 确认系统库版本是否满足要求 |
| 210 | + |
| 211 | +## 8. 训练 |
| 212 | + |
| 213 | +按照官方文档配置LineMOD数据集并开始训练。 |
| 214 | + |
| 215 | +## 参考资料 |
| 216 | + |
| 217 | +1. [FFB6D项目](https://github.com/ethnhe/FFB6D) |
| 218 | +2. [CUDA安装指南](https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html) |
| 219 | +3. [PyTorch安装指南](https://pytorch.org/get-started/locally/) |
| 220 | +4. [【论文笔记】FFB6D | 马浩飞丨博客](https://www.mahaofei.com/post/d027527.html) |
0 commit comments