- 首先配置好conda环境(需要提前安装ubuntu18.04和 anaconda或者miniconda)
原代码的说明里说可以选择安装python 3.6也可以装python2.7(我最开始的时候装的是python2.7版本的conda环境,但是折腾了很久,pytorch老装不上,可能是设备比较新的原因),
一直报错:
pose) smile@smile-X3-S-Series-GK7MR0R:~/miniconda3/envs/pose/src/singleshotpose/py2$ python train.py --datacfg cfg/ape.data --modelcfg cfg/yolo-pose.cfg --initweightfile cfg/darknet19_448.conv.23 --pretrain_num_epochs 15
Traceback (most recent call last):
File "train.py", line 4, in <module>
import torch
ModuleNotFoundError: No module named 'torch'
我的笔记本配置是RTX2060 、i7-10875H
接下来安装python 3.6的环境
conda create -n yolo6d python=3.6
创建结果:
(base) smile@smile-X3-S-Series-GK7MR0R:~/miniconda3/envs$ conda create -n yolo6d python=3.6
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /home/smile/miniconda3/envs/yolo6d
added / updated specs:
- python=3.6
The following packages will be downloaded:
package | build
---------------------------|-----------------
_libgcc_mutex-0.1 | conda_forge 3 KB conda-forge
_openmp_mutex-4.5 | 1_gnu 22 KB conda-forge
ca-certificates-2021.10.8 | ha878542_0 139 KB conda-forge
certifi-2016.9.26 | py36_0 217 KB conda-forge
ld_impl_linux-64-2.36.1 | hea4e1c9_2 667 KB conda-forge
libffi-3.4.2 | h7f98852_5 57 KB conda-forge
libgcc-ng-11.2.0 | h1d223b6_11 887 KB conda-forge
libgomp-11.2.0 | h1d223b6_11 427 KB conda-forge
libnsl-2.0.0 | h7f98852_0 31 KB conda-forge
libstdcxx-ng-11.2.0 | he4da1e4_11 4.2 MB conda-forge
libzlib-1.2.11 | h36c2ea0_1013 59 KB conda-forge
ncurses-6.2 | h58526e2_4 985 KB conda-forge
openssl-1.1.1l | h7f98852_0 2.1 MB conda-forge
pip-21.3.1 | pyhd8ed1ab_0 1.2 MB conda-forge
python-3.6.15 |hb7a2778_0_cpython 38.4 MB conda-forge
python_abi-3.6 | 2_cp36m 4 KB conda-forge
readline-8.1 | h46c0cb4_0 295 KB conda-forge
setuptools-49.6.0 | py36h5fab9bb_3 936 KB conda-forge
sqlite-3.37.0 | h9cd32fc_0 1.5 MB conda-forge
tk-8.6.11 | h27826a3_1 3.3 MB conda-forge
wheel-0.37.0 | pyhd8ed1ab_1 31 KB conda-forge
xz-5.2.5 | h516909a_1 343 KB conda-forge
zlib-1.2.11 | h36c2ea0_1013 86 KB conda-forge
------------------------------------------------------------
Total: 55.7 MB
The following NEW packages will be INSTALLED:
_libgcc_mutex conda-forge/linux-64::_libgcc_mutex-0.1-conda_forge
_openmp_mutex conda-forge/linux-64::_openmp_mutex-4.5-1_gnu
ca-certificates conda-forge/linux-64::ca-certificates-2021.10.8-ha878542_0
certifi conda-forge/linux-64::certifi-2016.9.26-py36_0
ld_impl_linux-64 conda-forge/linux-64::ld_impl_linux-64-2.36.1-hea4e1c9_2
libffi conda-forge/linux-64::libffi-3.4.2-h7f98852_5
libgcc-ng conda-forge/linux-64::libgcc-ng-11.2.0-h1d223b6_11
libgomp conda-forge/linux-64::libgomp-11.2.0-h1d223b6_11
libnsl conda-forge/linux-64::libnsl-2.0.0-h7f98852_0
libstdcxx-ng conda-forge/linux-64::libstdcxx-ng-11.2.0-he4da1e4_11
libzlib conda-forge/linux-64::libzlib-1.2.11-h36c2ea0_1013
ncurses conda-forge/linux-64::ncurses-6.2-h58526e2_4
openssl conda-forge/linux-64::openssl-1.1.1l-h7f98852_0
pip conda-forge/noarch::pip-21.3.1-pyhd8ed1ab_0
python conda-forge/linux-64::python-3.6.15-hb7a2778_0_cpython
python_abi conda-forge/linux-64::python_abi-3.6-2_cp36m
readline conda-forge/linux-64::readline-8.1-h46c0cb4_0
setuptools conda-forge/linux-64::setuptools-49.6.0-py36h5fab9bb_3
sqlite conda-forge/linux-64::sqlite-3.37.0-h9cd32fc_0
tk conda-forge/linux-64::tk-8.6.11-h27826a3_1
wheel conda-forge/noarch::wheel-0.37.0-pyhd8ed1ab_1
xz conda-forge/linux-64::xz-5.2.5-h516909a_1
zlib conda-forge/linux-64::zlib-1.2.11-h36c2ea0_1013
Proceed ([y]/n)? y
Downloading and Extracting Packages
libffi-3.4.2 | 57 KB | ##################################### | 100%
pip-21.3.1 | 1.2 MB | ##################################### | 100%
zlib-1.2.11 | 86 KB | ##################################### | 100%
_libgcc_mutex-0.1 | 3 KB | ##################################### | 100%
libgcc-ng-11.2.0 | 887 KB | ##################################### | 100%
libstdcxx-ng-11.2.0 | 4.2 MB | ##################################### | 100%
python-3.6.15 | 38.4 MB | ##################################### | 100%
_openmp_mutex-4.5 | 22 KB | ##################################### | 100%
readline-8.1 | 295 KB | ##################################### | 100%
tk-8.6.11 | 3.3 MB | ##################################### | 100%
ld_impl_linux-64-2.3 | 667 KB | ##################################### | 100%
certifi-2016.9.26 | 217 KB | ##################################### | 100%
setuptools-49.6.0 | 936 KB | ##################################### | 100%
ca-certificates-2021 | 139 KB | ##################################### | 100%
python_abi-3.6 | 4 KB | ##################################### | 100%
sqlite-3.37.0 | 1.5 MB | ##################################### | 100%
libnsl-2.0.0 | 31 KB | ##################################### | 100%
openssl-1.1.1l | 2.1 MB | ##################################### | 100%
xz-5.2.5 | 343 KB | ##################################### | 100%
libgomp-11.2.0 | 427 KB | ##################################### | 100%
ncurses-6.2 | 985 KB | ##################################### | 100%
libzlib-1.2.11 | 59 KB | ##################################### | 100%
wheel-0.37.0 | 31 KB | ##################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate yolo6d
#
# To deactivate an active environment, use
#
# $ conda deactivate
然后激活conda环境:
conda activate yolo6d
然后安装pytorch 0.4.1
conda install pytorch=0.4.1 torchvision cuda90 -c pytorch
安装结果:
(yolo6d) smile@smile-X3-S-Series-GK7MR0R:~/miniconda3/envs$ conda install pytorch=0.4.1 torchvision cuda90 -c pytorch
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: /home/smile/miniconda3/envs/yolo6d
added / updated specs:
- cuda90
- pytorch=0.4.1
- torchvision
The following packages will be downloaded:
package | build
---------------------------|-----------------
blas-1.0 | openblas 46 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ca-certificates-2021.10.26 | h06a4308_2 115 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
certifi-2020.6.20 | pyhd3eb1b0_3 155 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
cffi-1.14.6 | py36h400218f_0 220 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
intel-openmp-2021.4.0 | h06a4308_3561 4.2 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
jbig-2.1 | hdba287a_0 40 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
jpeg-9d | h7f8727e_0 232 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libffi-3.3 | he6710b0_2 50 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
libgfortran-3.0.0 | 1 281 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
libpng-1.6.37 | hbc83047_0 278 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
mkl-2021.4.0 | h06a4308_640 142.6 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
ninja-1.10.2 | h5e70eb0_2 1.5 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
numpy-1.13.1 | py36_nomkl_0 7.2 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
olefile-0.46 | py36_0 48 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
openblas-0.2.19 | 0 3.0 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
pillow-4.2.1 | py36_0 870 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
pycparser-2.21 | pyhd3eb1b0_0 94 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
python-3.6.13 | h12debd9_1 32.5 MB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
pytorch-0.4.1 |py36_py35_py27__9.0.176_7.1.2_2 471.7 MB pytorch
six-1.16.0 | pyhd3eb1b0_0 18 KB https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
torchvision-0.2.1 | py_2 37 KB pytorch
------------------------------------------------------------
Total: 665.1 MB
The following NEW packages will be INSTALLED:
blas anaconda/pkgs/main/linux-64::blas-1.0-openblas
cffi anaconda/pkgs/main/linux-64::cffi-1.14.6-py36h400218f_0
cuda90 pytorch/linux-64::cuda90-1.0-h6433d27_0
freetype anaconda/pkgs/free/linux-64::freetype-2.5.5-2
intel-openmp anaconda/pkgs/main/linux-64::intel-openmp-2021.4.0-h06a4308_3561
jbig anaconda/pkgs/main/linux-64::jbig-2.1-hdba287a_0
jpeg anaconda/pkgs/main/linux-64::jpeg-9d-h7f8727e_0
libgfortran anaconda/pkgs/free/linux-64::libgfortran-3.0.0-1
libpng anaconda/pkgs/main/linux-64::libpng-1.6.37-hbc83047_0
libtiff anaconda/pkgs/free/linux-64::libtiff-4.0.6-3
mkl anaconda/pkgs/main/linux-64::mkl-2021.4.0-h06a4308_640
ninja anaconda/pkgs/main/linux-64::ninja-1.10.2-h5e70eb0_2
numpy anaconda/pkgs/free/linux-64::numpy-1.13.1-py36_nomkl_0
olefile anaconda/pkgs/main/linux-64::olefile-0.46-py36_0
openblas anaconda/pkgs/free/linux-64::openblas-0.2.19-0
pillow anaconda/pkgs/free/linux-64::pillow-4.2.1-py36_0
pycparser anaconda/pkgs/main/noarch::pycparser-2.21-pyhd3eb1b0_0
pytorch pytorch/linux-64::pytorch-0.4.1-py36_py35_py27__9.0.176_7.1.2_2
six anaconda/pkgs/main/noarch::six-1.16.0-pyhd3eb1b0_0
torchvision pytorch/noarch::torchvision-0.2.1-py_2
The following packages will be UPDATED:
ca-certificates anaconda/cloud/conda-forge::ca-certif~ --> anaconda/pkgs/main::ca-certificates-2021.10.26-h06a4308_2
certifi anaconda/cloud/conda-forge/linux-64::~ --> anaconda/pkgs/main/noarch::certifi-2020.6.20-pyhd3eb1b0_3
The following packages will be SUPERSEDED by a higher-priority channel:
libffi anaconda/cloud/conda-forge::libffi-3.~ --> anaconda/pkgs/main::libffi-3.3-he6710b0_2
python anaconda/cloud/conda-forge::python-3.~ --> anaconda/pkgs/main::python-3.6.13-h12debd9_1
Proceed ([y]/n)? y
Downloading and Extracting Packages
numpy-1.13.1 | 7.2 MB | ##################################### | 100%
libpng-1.6.37 | 278 KB | ##################################### | 100%
pycparser-2.21 | 94 KB | ##################################### | 100%
pillow-4.2.1 | 870 KB | ##################################### | 100%
ninja-1.10.2 | 1.5 MB | ##################################### | 100%
mkl-2021.4.0 | 142.6 MB | ##################################### | 100%
jbig-2.1 | 40 KB | ##################################### | 100%
libffi-3.3 | 50 KB | ##################################### | 100%
certifi-2020.6.20 | 155 KB | ##################################### | 100%
ca-certificates-2021 | 115 KB | ##################################### | 100%
olefile-0.46 | 48 KB | ##################################### | 100%
pytorch-0.4.1 | 471.7 MB | ##################################### | 100%
torchvision-0.2.1 | 37 KB | ##################################### | 100%
six-1.16.0 | 18 KB | ##################################### | 100%
cffi-1.14.6 | 220 KB | ##################################### | 100%
intel-openmp-2021.4. | 4.2 MB | ##################################### | 100%
openblas-0.2.19 | 3.0 MB | ##################################### | 100%
libgfortran-3.0.0 | 281 KB | ##################################### | 100%
jpeg-9d | 232 KB | ##################################### | 100%
blas-1.0 | 46 KB | ##################################### | 100%
python-3.6.13 | 32.5 MB | ##################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
如果你安全上网了,可能会报错:
(yolo6d) smile@smile-X3-S-Series-GK7MR0R:~/miniconda3/envs$ conda install torchvison
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- torchvison
Current channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/noarch
- https://repo.anaconda.com/pkgs/main/linux-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/linux-64
- https://repo.anaconda.com/pkgs/r/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
- 把源码拷贝到anaconda的对应环境的文件夹下,这是我的miniconda的文件夹:/home/smile/miniconda3/envs
相关权重文件我也都放进去了:
- pycharm打开源码文件夹,并且将pycharm的编译器设置为最开始我们创建的conda的编译器:
在pycharm下进行终端操作:
(base) smile@smile-X3-S-Series-GK7MR0R:~/miniconda3/envs/yolo6d$ conda activate yolo6d
然后我按源代码的教程开始训练,发现少安装了cv2
(yolo6d) smile@smile-X3-S-Series-GK7MR0R:~/miniconda3/envs/yolo6d/src$ ls
date singleshotpose
(yolo6d) smile@smile-X3-S-Series-GK7MR0R:~/miniconda3/envs/yolo6d/src$ cd singleshotpose/
(yolo6d) smile@smile-X3-S-Series-GK7MR0R:~/miniconda3/envs/yolo6d/src/singleshotpose$ ls
backup cfg.pyc dataset.pyc LICENSE MeshPly.pyc region_loss.py utils.pyc valid.py
backup_multi darknet.py image.py LICENSE.txt multi_obj_pose_estimation region_loss.pyc valid.ipynb VOCdevkit
cfg darknet.pyc image.pyc LINEMOD py2 train.py 'valid _multi.ipynb' weightfile
cfg.py dataset.py label_file_creation.md MeshPly.py README.md utils.py 'valid _multi.py'
(yolo6d) smile@smile-X3-S-Series-GK7MR0R:~/miniconda3/envs/yolo6d/src/singleshotpose$ python train.py --datacfg cfg/ape.data --modelcfg cfg/yolo-pose.cfg --initweightfile cfg/darknet19_448.conv.23 --pretrain_num_epochs 15
Traceback (most recent call last):
File "train.py", line 18, in <module>
import dataset
File "/home/smile/miniconda3/envs/yolo6d/src/singleshotpose/dataset.py", line 12, in <module>
from utils import read_truths_args, read_truths, get_all_files
File "/home/smile/miniconda3/envs/yolo6d/src/singleshotpose/utils.py", line 10, in <module>
import cv2
ModuleNotFoundError: No module named 'cv2'
少什么包就安装什么包:pip install opencv-python
后面又报:AttributeError: module 'PIL.Image' has no attribute 'register_extensions' 到网上查了一下解决方法 ![在这里插入图片描述](https://img-blog.csdnimg.cn/450700509db443218a6f4f2099b94b02.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAcXFfNDQ2NDk5NDU=,size_20,color_FFFFFF,t_70,g_se,x_16) 大概意思是让安装
pip install pillow、
pip install image`就可以跑了
conda镜像源配置文件并修改
我的conda的源配置(用的清华的源)
(base) smile@smile-X3-S-Series-GK7MR0R:~$ conda config --show-sources
==> /home/smile/.condarc <==
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- defaults
show_channel_urls: True
版权声明:本文为CSDN博主「大家好我是家盛」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_44649945/article/details/121736591
暂无评论