python=3.6
cudatoolkit=10.0
pytorch=1.0
torchvision=0.2.1
conda create --name FCOS python=3.6 #创建虚拟环境,python为3.6版本
source activate FCOS #激活虚拟环境
python #查看python版本,看不看都行,就是确认一下
conda install ipython
pip install ninja yacs cython matplotlib tqdm opencv-python
conda install pytorch==1.0.0 torchvision==0.2.1 cuda100 -c pytorch
conda install torchvision=0.2.1
conda install cudatoolkit=10.0
要运行test.py
,首先得运行setup.py
python setup.py build develop
a) windows
error: Microsoft Visual C++ 14.0 or grearter is required.
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/
visual-cpp-build-tools/
解决 安装vs c++ 14 以上版本
vs_buildtools__1431063600.1635214871.exe
再一次运行setup.py
python setup.py build develop
crosoft Visual Studio version! Only the versions 2012, 2013, 2015 and 2017 are supported!
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.2\include\crt\host_config.h
中 大概133~131
行修改成:Visual Studio version | _MSC_VER |
---|---|
Visual Studio 6.0 | 1200 |
Visual Studio .NET 2002 (7.0) | 1300 |
Visual Studio .NET 2003 (7.1) | 1310 |
Visual Studio 2005 (8.0) | 1400 |
Visual Studio 2008 (9.0) | 1500 |
Visual Studio 2010 (10.0) | 1600 |
Visual Studio 2012 (11.0) | 1700 |
Visual Studio 2013 (12.0) | 1800 |
Visual Studio 2015 (14.0) | 1900 |
Visual Studio 2017 RTW (15.0) | 1910 |
Visual Studio 2017 version 15.3 | 1911 |
Visual Studio 2017 version 15.5 | 1912 |
Visual Studio 2017 version 15.6 | 1913 |
Visual Studio 2017 version 15.7 | 1914 |
Visual Studio 2017 version 15.8 | 1915 |
Visual Studio 2017 version 15.9 | 1916 |
Visual Studio 2019 RTW (16.0) | 1920 |
Visual Studio 2019 version 16.1 | 1921 |
Visual Studio 2019 version 16.2 | 1922 |
Visual Studio 2019 version 16.3 | 1923 |
Visual Studio 2019 version 16.4 | 1924 |
Visual Studio 2019 version 16.5 | 1925 |
Visual Studio 2019 version 16.6 | 1926 |
Visual Studio 2019 version 16.7 | 1927 |
选择自己vs相应版本的数值
python3.7 pytorch 与torchvision、cudatoolkit
不配python=3.6+cudatoolkit=10.0+torch=1.0+torchvision=0.2.1
python tools/test_net.py \
--config-file configs/fcos/fcos_imprv_R_50_FPN_1x.yaml \
MODEL.WEIGHT FCOS_imprv_R_50_FPN_1x.pth \
TEST.IMS_PER_BATCH 4
AttributeError: module 'torch._six' has no attribute 'PY3'
python/FCOS/FCOS/fcos_core/utils/imports.py
将PY37改为PY3 # 因为我的python版本是3.6
pip install pycocotools
再运行测试文件
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcf in position 0: ordinal not in range(128)
if sys.getdefaultencoding() != 'gbk':
reload(sys)
sys.setdefaultencoding('gbk')
但是,我发现还是报这个错误
于是我在网上搜了一下发现可以这样解决:
cd XXX #XXX为你想把FCOS文件放的目录
cd $INSTALL_DIR
# 使用github记得
pip install git+https://github.com/philferriere /cocoapi.git#subdirectory=PythonAPI
git clone https://github.com/cocodataset/cocoapi.git
cd cocoapi/PythonAPI
python setup.py build_ext install
报错 cl: 命令行 error D8021 :无效的数值参数“/Wno-cpp”
解决
打开coco\PythonAPI
目录下的 setup.py
文件,
修改ext_modules extra_compile_args=['-Wno-cpp', '-Wno-unused-function', '-std=c99'],
成功解决!
之后运行
cd XXX #XXX为你想把FCOS文件放的目录
cd $INSTALL_DIR
git clone https://github.com/tianzhi0549/FCOS.git
cd FCOS
python setup.py build develop --no-deps
之后运行demo
wget https://cloudstor.aarnet.edu.au/plus/s/ZSAqNJB96hA71Yf/download -O FCOS_imprv_R_50_FPN_1x.pth
python demo/fcos_demo.py
结果
成功!!
b) Ubuntu 20.04
g++: error: /home/XXX/XXX/CodeProject/FCOS-master/build/temp.linux-x86_64-3.8/fcos_core/csrc/vision.o: No such file or directory
g++: error: /home/XXX/XXX/CodeProject/FCOS-master/build/temp.linux-x86_64-3.8/fcos_core/csrc/cpu/nms_cpu.o: No such file or directory
g++: error: /home/XXX/XXX/CodeProject/FCOS-master/build/temp.linux-x86_64-3.8/fcos_core/csrc/cpu/ROIAlign_cpu.o: No such file or directory
解决
cd /home/XXX/XXX/CodeProject/FCOS-master/build/temp.linux-x86_64-3.8/fcos_core/csrc
sudo vim vision.o
:wq
cd cpu
sudo vim nms_cpu.o
:wq
sudo vim ROIAlign_cpu.o
:wq
成功
___________________________________________________________
ubuntu 执行运行测试的命令:
python tools/test_net.py \
--config-file configs/fcos/fcos_imprv_R_50_FPN_1x.yaml \
MODEL.WEIGHT FCOS_imprv_R_50_FPN_1x.pth \
TEST.IMS_PER_BATCH 4
2.出现以下问题:AttributeError: module 'torch._six' has no attribute 'PY3'
解决 修改文件python/FCOS/FCOS/fcos_core/utils/imports.py
将PY3改为PY37
成功再次运行test_net.py
3.出现以下问题:/_C.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZN2at19UndefinedTensorImpl10_singletonE
解决 cuda和pytorch不匹配导致的上述错误,之前就是pytorch=3.7
所以将其降成python=3.6
python=3.6+cudatoolkit=10.0+torch=1.0+torchvision=0.2.1
4.每次import torch 都会报错问题如下:
`Traceback (most recent call last):
File "" , line 1, in <module>
File "xxxxx/site-packages/torch/__init__.py", line 84, in <module>
from torch._C import *
ImportError: xxxxx/site-packages/torch/lib/libmkldnn.so.0: undefined symbol: cblas_sgemm_a`
conda install -c anaconda mkl
cd XXX #XXX为你想把FCOS文件放的目录
cd $INSTALL_DIR
#必须
git clone https://github.com/cocodataset/cocoapi.git
但是ubuntu是服务器,很麻烦,于是修改git clone
这个一定能成功!
git clone https://gitee.com/ericzhou2018/cocoapi
cd cocoapi/PythonAPI
python setup.py build_ext install
cd $INSTALL_DIR
python setup.py build develop --no-deps
5.出现问题:error: could not create 'build/lib.linux-x86_64-3.6': Permission denied
解决,运行sudo chmod 777 XXX文件
再接着运行python setup.py build develop --no-deps
成功!
接着,测试demo
wget https://cloudstor.aarnet.edu.au/plus/s/ZSAqNJB96hA71Yf/download -O FCOS_imprv_R_50_FPN_1x.pth
python demo/fcos_demo.py
6.出现问题:AttributeError: module 'torch._six' has no attribute 'PY37'
解决:将PY37
改回PY3
7.又出现问题ImportError: numpy.core.multiarray failed to import
升级numy
版本
pip uninstall numpy # 看看之前是用pip还是conda安装
conda install numpy
成功!
之后,再次运行
python demo/fcos_demo.py