Open DataXujing opened 3 years ago
也尝试过,也是相同的error,我可不可以在models/ common.py
中基于Pytorch重新给个Mish激活函数的定义?如下:
# no pretrain
# from mish_cuda import MishCuda as Mish
# pretrain
#from mc.build.lib.mish_mish import MishCuda as Mish
# 实在装不上mish-cuda,用pytorch自己实现
class Mish(nn.Module):
def __init__(self):
super().__init__()
def forward(self,x):
x = x * (torch.tanh(F.softplus(x)))
return x
这样我训练是可以正常训练的,但是不确定这个Mish-cuda和Mish激活函数的区别在哪,求大佬答疑解惑!
使用的RAM差很多(約1.8倍) 還有速度差很多(約1.2倍)
好的,明白!
GPU=2080s 在镜像pytorch:20.06-py3下使用https://github.com/thomasbrandon/mish-cuda不能正常编译,https://github.com/JunnYu/mish-cuda则可以。
GPU=2080s 在镜像pytorch:20.06-py3下使用https://github.com/thomasbrandon/mish-cuda不能正常编译,https://github.com/JunnYu/mish-cuda则可以。
这边也是同样的情况,2080ti,pytorch:20.06-py3镜像,驱动版本450,用https://github.com/thomasbrandon/mish-cuda的一直提示编译失败,换成https://github.com/JunnYu/mish-cuda则可以。
thomasbrandon版本的编译失败报错信息:
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/mish_cuda
copying src/mish_cuda/__init__.py -> build/lib.linux-x86_64-3.6/mish_cuda
running egg_info
creating src/mish_cuda.egg-info
writing src/mish_cuda.egg-info/PKG-INFO
writing dependency_links to src/mish_cuda.egg-info/dependency_links.txt
writing requirements to src/mish_cuda.egg-info/requires.txt
writing top-level names to src/mish_cuda.egg-info/top_level.txt
writing manifest file 'src/mish_cuda.egg-info/SOURCES.txt'
reading manifest file 'src/mish_cuda.egg-info/SOURCES.txt'
writing manifest file 'src/mish_cuda.egg-info/SOURCES.txt'
running build_ext
building 'mish_cuda._C' extension
creating /mish-cuda/build/temp.linux-x86_64-3.6
creating /mish-cuda/build/temp.linux-x86_64-3.6/csrc
Emitting ninja build file /mish-cuda/build/temp.linux-x86_64-3.6/build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
[1/3] /usr/local/cuda/bin/nvcc -Iexternal -I/opt/conda/lib/python3.6/site-packages/torch/include -I/opt/conda/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -I/opt/conda/lib/python3.6/site-packages/torch/include/TH -I/opt/conda/lib/python3.6/site-packages/torch/include/THC -I/usr/local/cuda/include -I/opt/conda/include/python3.6m -c -c /mish-cuda/csrc/mish_kernel.cu -o /mish-cuda/build/temp.linux-x86_64-3.6/csrc/mish_kernel.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options '-fPIC' --expt-extended-lambda -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=1 -gencode=arch=compute_61,code=sm_61 -gencode=arch=compute_70,code=sm_70 -gencode=arch=compute_80,code=compute_80 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_80,code=sm_80 -gencode=arch=compute_75,code=sm_75 -gencode=arch=compute_52,code=sm_52 -std=c++14
FAILED: /mish-cuda/build/temp.linux-x86_64-3.6/csrc/mish_kernel.o
/usr/local/cuda/bin/nvcc -Iexternal -I/opt/conda/lib/python3.6/site-packages/torch/include -I/opt/conda/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -I/opt/conda/lib/python3.6/site-packages/torch/include/TH -I/opt/conda/lib/python3.6/site-packages/torch/include/THC -I/usr/local/cuda/include -I/opt/conda/include/python3.6m -c -c /mish-cuda/csrc/mish_kernel.cu -o /mish-cuda/build/temp.linux-x86_64-3.6/csrc/mish_kernel.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options '-fPIC' --expt-extended-lambda -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=1 -gencode=arch=compute_61,code=sm_61 -gencode=arch=compute_70,code=sm_70 -gencode=arch=compute_80,code=compute_80 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_80,code=sm_80 -gencode=arch=compute_75,code=sm_75 -gencode=arch=compute_52,code=sm_52 -std=c++14
/mish-cuda/csrc/mish_kernel.cu:3:10: fatal error: CUDAApplyUtils.cuh: No such file or directory
#include "CUDAApplyUtils.cuh"
^~~~~~~~~~~~~~~~~~~~
compilation terminated.
[2/3] c++ -MMD -MF /mish-cuda/build/temp.linux-x86_64-3.6/csrc/mish_cpu.o.d -pthread -B /opt/conda/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Iexternal -I/opt/conda/lib/python3.6/site-packages/torch/include -I/opt/conda/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -I/opt/conda/lib/python3.6/site-packages/torch/include/TH -I/opt/conda/lib/python3.6/site-packages/torch/include/THC -I/usr/local/cuda/include -I/opt/conda/include/python3.6m -c -c /mish-cuda/csrc/mish_cpu.cpp -o /mish-cuda/build/temp.linux-x86_64-3.6/csrc/mish_cpu.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++14
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
[3/3] c++ -MMD -MF /mish-cuda/build/temp.linux-x86_64-3.6/csrc/mish_cuda.o.d -pthread -B /opt/conda/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Iexternal -I/opt/conda/lib/python3.6/site-packages/torch/include -I/opt/conda/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -I/opt/conda/lib/python3.6/site-packages/torch/include/TH -I/opt/conda/lib/python3.6/site-packages/torch/include/THC -I/usr/local/cuda/include -I/opt/conda/include/python3.6m -c -c /mish-cuda/csrc/mish_cuda.cpp -o /mish-cuda/build/temp.linux-x86_64-3.6/csrc/mish_cuda.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++14
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
File "/opt/conda/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1471, in _run_ninja_build
check=True)
File "/opt/conda/lib/python3.6/subprocess.py", line 438, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "setup.py", line 30, in <module>
'build_ext': BuildExtension
File "/opt/conda/lib/python3.6/site-packages/setuptools/__init__.py", line 161, in setup
return distutils.core.setup(**attrs)
File "/opt/conda/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/opt/conda/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/opt/conda/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/opt/conda/lib/python3.6/distutils/command/build.py", line 135, in run
self.run_command(cmd_name)
File "/opt/conda/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/opt/conda/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/opt/conda/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 87, in run
_build_ext.run(self)
File "/opt/conda/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
_build_ext.build_ext.run(self)
File "/opt/conda/lib/python3.6/distutils/command/build_ext.py", line 339, in run
self.build_extensions()
File "/opt/conda/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 633, in build_extensions
build_ext.build_extensions(self)
File "/opt/conda/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 194, in build_extensions
self.build_extension(ext)
File "/opt/conda/lib/python3.6/site-packages/setuptools/command/build_ext.py", line 208, in build_extension
_build_ext.build_extension(self, ext)
File "/opt/conda/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
depends=ext.depends)
File "/opt/conda/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 462, in unix_wrap_ninja_compile
with_cuda=with_cuda)
File "/opt/conda/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1211, in _write_ninja_file_and_compile_objects
error_prefix='Error compiling objects for extension')
File "/opt/conda/lib/python3.6/site-packages/torch/utils/cpp_extension.py", line 1484, in _run_ninja_build
raise RuntimeError(message)
RuntimeError: Error compiling objects for extension
JunnYu的编译成功信息:
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/mish_cuda
copying src/mish_cuda/__init__.py -> build/lib.linux-x86_64-3.6/mish_cuda
running egg_info
creating src/mish_cuda.egg-info
writing src/mish_cuda.egg-info/PKG-INFO
writing dependency_links to src/mish_cuda.egg-info/dependency_links.txt
writing requirements to src/mish_cuda.egg-info/requires.txt
writing top-level names to src/mish_cuda.egg-info/top_level.txt
writing manifest file 'src/mish_cuda.egg-info/SOURCES.txt'
reading manifest file 'src/mish_cuda.egg-info/SOURCES.txt'
writing manifest file 'src/mish_cuda.egg-info/SOURCES.txt'
running build_ext
building 'mish_cuda._C' extension
creating /mish-cuda/build/temp.linux-x86_64-3.6
creating /mish-cuda/build/temp.linux-x86_64-3.6/csrc
creating /mish-cuda/build/temp.linux-x86_64-3.6/csrc/cpu
creating /mish-cuda/build/temp.linux-x86_64-3.6/csrc/cuda
Emitting ninja build file /mish-cuda/build/temp.linux-x86_64-3.6/build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
[1/3] c++ -MMD -MF /mish-cuda/build/temp.linux-x86_64-3.6/csrc/cpu/mish_cpu.o.d -pthread -B /opt/conda/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/conda/lib/python3.6/site-packages/torch/include -I/opt/conda/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -I/opt/conda/lib/python3.6/site-packages/torch/include/TH -I/opt/conda/lib/python3.6/site-packages/torch/include/THC -I/usr/local/cuda/include -I/opt/conda/include/python3.6m -c -c /mish-cuda/csrc/cpu/mish_cpu.cpp -o /mish-cuda/build/temp.linux-x86_64-3.6/csrc/cpu/mish_cpu.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++14
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
[2/3] c++ -MMD -MF /mish-cuda/build/temp.linux-x86_64-3.6/csrc/cuda/mish_cuda.o.d -pthread -B /opt/conda/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/opt/conda/lib/python3.6/site-packages/torch/include -I/opt/conda/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -I/opt/conda/lib/python3.6/site-packages/torch/include/TH -I/opt/conda/lib/python3.6/site-packages/torch/include/THC -I/usr/local/cuda/include -I/opt/conda/include/python3.6m -c -c /mish-cuda/csrc/cuda/mish_cuda.cpp -o /mish-cuda/build/temp.linux-x86_64-3.6/csrc/cuda/mish_cuda.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++14
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
[3/3] /usr/local/cuda/bin/nvcc -I/opt/conda/lib/python3.6/site-packages/torch/include -I/opt/conda/lib/python3.6/site-packages/torch/include/torch/csrc/api/include -I/opt/conda/lib/python3.6/site-packages/torch/include/TH -I/opt/conda/lib/python3.6/site-packages/torch/include/THC -I/usr/local/cuda/include -I/opt/conda/include/python3.6m -c -c /mish-cuda/csrc/cuda/mish_kernel.cu -o /mish-cuda/build/temp.linux-x86_64-3.6/csrc/cuda/mish_kernel.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options '-fPIC' --expt-extended-lambda -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=1 -gencode=arch=compute_70,code=sm_70 -gencode=arch=compute_80,code=compute_80 -gencode=arch=compute_75,code=sm_75 -gencode=arch=compute_80,code=sm_80 -gencode=arch=compute_61,code=sm_61 -gencode=arch=compute_52,code=sm_52 -gencode=arch=compute_60,code=sm_60 -std=c++14
g++ -pthread -shared -B /opt/conda/compiler_compat -L/opt/conda/lib -Wl,-rpath=/opt/conda/lib -Wl,--no-as-needed -Wl,--sysroot=/ /mish-cuda/build/temp.linux-x86_64-3.6/csrc/cpu/mish_cpu.o /mish-cuda/build/temp.linux-x86_64-3.6/csrc/cuda/mish_cuda.o /mish-cuda/build/temp.linux-x86_64-3.6/csrc/cuda/mish_kernel.o -L/opt/conda/lib/python3.6/site-packages/torch/lib -L/usr/local/cuda/lib64 -lc10 -ltorch -ltorch_cpu -ltorch_python -lcudart -lc10_cuda -ltorch_cuda -o build/lib.linux-x86_64-3.6/mish_cuda/_C.cpython-36m-x86_64-linux-gnu.so
running install
running bdist_egg
installing library code to build/bdist.linux-x86_64/egg
running install_lib
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/mish_cuda
copying build/lib.linux-x86_64-3.6/mish_cuda/_C.cpython-36m-x86_64-linux-gnu.so -> build/bdist.linux-x86_64/egg/mish_cuda
copying build/lib.linux-x86_64-3.6/mish_cuda/__init__.py -> build/bdist.linux-x86_64/egg/mish_cuda
byte-compiling build/bdist.linux-x86_64/egg/mish_cuda/__init__.py to __init__.cpython-36.pyc
creating stub loader for mish_cuda/_C.cpython-36m-x86_64-linux-gnu.so
byte-compiling build/bdist.linux-x86_64/egg/mish_cuda/_C.py to _C.cpython-36.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying src/mish_cuda.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying src/mish_cuda.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying src/mish_cuda.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying src/mish_cuda.egg-info/not-zip-safe -> build/bdist.linux-x86_64/egg/EGG-INFO
copying src/mish_cuda.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying src/mish_cuda.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
creating dist
creating 'dist/mish_cuda-0.0.3-py3.6-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing mish_cuda-0.0.3-py3.6-linux-x86_64.egg
creating /opt/conda/lib/python3.6/site-packages/mish_cuda-0.0.3-py3.6-linux-x86_64.egg
Extracting mish_cuda-0.0.3-py3.6-linux-x86_64.egg to /opt/conda/lib/python3.6/site-packages
Adding mish-cuda 0.0.3 to easy-install.pth file
Installed /opt/conda/lib/python3.6/site-packages/mish_cuda-0.0.3-py3.6-linux-x86_64.egg
Processing dependencies for mish-cuda==0.0.3
Searching for torch==1.6.0a0+9907a3e
Best match: torch 1.6.0a0+9907a3e
Adding torch 1.6.0a0+9907a3e to easy-install.pth file
Installing convert-caffe2-to-onnx script to /opt/conda/bin
Installing convert-onnx-to-caffe2 script to /opt/conda/bin
Using /opt/conda/lib/python3.6/site-packages
Searching for future==0.18.2
Best match: future 0.18.2
Adding future 0.18.2 to easy-install.pth file
Installing futurize script to /opt/conda/bin
Installing pasteurize script to /opt/conda/bin
Using /opt/conda/lib/python3.6/site-packages
Searching for numpy==1.18.1
Best match: numpy 1.18.1
Adding numpy 1.18.1 to easy-install.pth file
Installing f2py script to /opt/conda/bin
Installing f2py3 script to /opt/conda/bin
Installing f2py3.6 script to /opt/conda/bin
Using /opt/conda/lib/python3.6/site-packages
Finished processing dependencies for mish-cuda==0.0.3
@DataXujing 请问您这边安装好mish-cuda了吗? @WongKinYiu 如果换成JunnYu版本的mish-cuda,还需要修改哪些代码吗?
不用pretrianed model就都不用改 要用的話就要把有出現mish_cuda的部分都改成mish_mish
不需要用mosaic怎么修改
"JunnYu"版本安装成功。(CentOS 8.3 ,Driver Version: 455.45.01,CUDA 10.1 ,TITAN X,python 3.6.8,torch 1.5.0,gcc version 8.4.1 ) 方式: 1、git clone到本地; 2、cd 到根目录; 3、确保已安装gcc的c++支持(dnf install gcc-c++); 4、运行:python setup.py install
JunnYu's mish version compiled successfully!, https://github.com/JunnYu/mish-cuda (Ubuntu20.04, Drivier: 460.27.04, CUDA:11.2, Pytorch1.8)
`(pytorch) xiaopeng@xiaopeng-HP-Z800-Workstation:~/ScaledYOLOv4-yolov4-csp/mish-cuda$ python setup.py build install /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/distutils/extension.py:131: UserWarning: Unknown Extension options: 'headers' warnings.warn(msg) running build running build_py creating build creating build/lib.linux-x86_64-3.7 creating build/lib.linux-x86_64-3.7/mish_cuda copying src/mish_cuda/init.py -> build/lib.linux-x86_64-3.7/mish_cuda running egg_info creating src/mish_cuda.egg-info writing src/mish_cuda.egg-info/PKG-INFO writing dependency_links to src/mish_cuda.egg-info/dependency_links.txt writing requirements to src/mish_cuda.egg-info/requires.txt writing top-level names to src/mish_cuda.egg-info/top_level.txt writing manifest file 'src/mish_cuda.egg-info/SOURCES.txt' reading manifest file 'src/mish_cuda.egg-info/SOURCES.txt' writing manifest file 'src/mish_cuda.egg-info/SOURCES.txt' running build_ext building 'mish_cuda._C' extension creating /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7 creating /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc creating /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc/cpu creating /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc/cuda Emitting ninja build file /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/build.ninja... Compiling objects... Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N) [1/3] :/usr/local/cuda/bin/nvcc -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/TH -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/THC -I:/usr/local/cuda/include -I/home/xiaopeng/miniconda3/envs/pytorch/include/python3.7m -c -c /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/csrc/cuda/mish_kernel.cu -o /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc/cuda/mish_kernel.o -DCUDA_NO_HALF_OPERATORS -DCUDA_NO_HALF_CONVERSIONS -DCUDA_NO_HALF2_OPERATORS --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' --expt-extended-lambda -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_61,code=sm_61 -std=c++14 FAILED: /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc/cuda/mish_kernel.o :/usr/local/cuda/bin/nvcc -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/TH -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/THC -I:/usr/local/cuda/include -I/home/xiaopeng/miniconda3/envs/pytorch/include/python3.7m -c -c /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/csrc/cuda/mish_kernel.cu -o /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc/cuda/mish_kernel.o -DCUDA_NO_HALF_OPERATORS -DCUDA_NO_HALF_CONVERSIONS -DCUDA_NO_HALF2_OPERATORS --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' --expt-extended-lambda -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_61,code=sm_61 -std=c++14 /bin/sh: 1: :/usr/local/cuda/bin/nvcc: not found [2/3] c++ -MMD -MF /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc/cpu/mish_cpu.o.d -pthread -B /home/xiaopeng/miniconda3/envs/pytorch/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/TH -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/THC -I:/usr/local/cuda/include -I/home/xiaopeng/miniconda3/envs/pytorch/include/python3.7m -c -c /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/csrc/cpu/mish_cpu.cpp -o /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc/cpu/mish_cpu.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14 cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ In file included from /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/ATen/Parallel.h:149, from /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/ATen/CPUApplyUtils.h:3, from /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/csrc/cpu/mish_cpu.cpp:3: /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/ATen/ParallelOpenMP.h:84: warning: ignoring #pragma omp parallel [-Wunknown-pragmas] 84 | #pragma omp parallel for if ((end - begin) >= grain_size) |
---|
[3/3] c++ -MMD -MF /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc/cuda/mish_cuda.o.d -pthread -B /home/xiaopeng/miniconda3/envs/pytorch/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/TH -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/THC -I:/usr/local/cuda/include -I/home/xiaopeng/miniconda3/envs/pytorch/include/python3.7m -c -c /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/csrc/cuda/mish_cuda.cpp -o /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc/cuda/mish_cuda.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14 cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ In file included from /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/ATen/Parallel.h:149, from /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/utils.h:3, from /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/nn/cloneable.h:5, from /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/nn.h:3, from /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/all.h:12, from /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/extension.h:4, from /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/csrc/cuda/mish_cuda.cpp:2: /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/ATen/ParallelOpenMP.h:84: warning: ignoring #pragma omp parallel [-Wunknown-pragmas] 84 | #pragma omp parallel for if ((end - begin) >= grain_size) |
---|
ninja: build stopped: subcommand failed. Traceback (most recent call last): File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1522, in _run_ninja_build env=env) File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/subprocess.py", line 512, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "setup.py", line 29, in
@trikim 我用的是cuda11.0,ubuntu20.04.两个版本的mish都试了。都不行。 你碰见过这个错误吗 @WongKinYiu @DataXujing @JustinhoCHN
也尝试过,也是相同的error,我可不可以在
models/ common.py
中基于Pytorch重新给个Mish激活函数的定义?如下:# no pretrain # from mish_cuda import MishCuda as Mish # pretrain #from mc.build.lib.mish_mish import MishCuda as Mish # 实在装不上mish-cuda,用pytorch自己实现 class Mish(nn.Module): def __init__(self): super().__init__() def forward(self,x): x = x * (torch.tanh(F.softplus(x))) return x
这样我训练是可以正常训练的,但是不确定这个Mish-cuda和Mish激活函数的区别在哪,求大佬答疑解惑!
@DataXujing 我在实验室另一台电脑上成功了。pytorch1.4 cuda10.1 但是我自己的服务器却失败了。
也尝试过,也是相同的error,我可不可以在
models/ common.py
中基于Pytorch重新给个Mish激活函数的定义?如下:# no pretrain # from mish_cuda import MishCuda as Mish # pretrain #from mc.build.lib.mish_mish import MishCuda as Mish # 实在装不上mish-cuda,用pytorch自己实现 class Mish(nn.Module): def __init__(self): super().__init__() def forward(self,x): x = x * (torch.tanh(F.softplus(x))) return x
这样我训练是可以正常训练的,但是不确定这个Mish-cuda和Mish激活函数的区别在哪,求大佬答疑解惑!
我想请问一下 这个F是什么
第一位编译不过去的可以这么操作,把external/CUDAApplyUtils.cuh拷贝到csrc目录下: cp external/CUDAApplyUtils.cuh csrc/
`(pytorch) xiaopeng@xiaopeng-HP-Z800-Workstation:~/ScaledYOLOv4-yolov4-csp/mish-cuda$ python setup.py build install /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/distutils/extension.py:131: UserWarning: Unknown Extension options: 'headers' warnings.warn(msg) running build running build_py creating build creating build/lib.linux-x86_64-3.7 creating build/lib.linux-x86_64-3.7/mish_cuda copying src/mish_cuda/init.py -> build/lib.linux-x86_64-3.7/mish_cuda running egg_info creating src/mish_cuda.egg-info writing src/mish_cuda.egg-info/PKG-INFO writing dependency_links to src/mish_cuda.egg-info/dependency_links.txt writing requirements to src/mish_cuda.egg-info/requires.txt writing top-level names to src/mish_cuda.egg-info/top_level.txt writing manifest file 'src/mish_cuda.egg-info/SOURCES.txt' reading manifest file 'src/mish_cuda.egg-info/SOURCES.txt' writing manifest file 'src/mish_cuda.egg-info/SOURCES.txt' running build_ext building 'mish_cuda._C' extension creating /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7 creating /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc creating /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc/cpu creating /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc/cuda Emitting ninja build file /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/build.ninja... Compiling objects... Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N) [1/3] :/usr/local/cuda/bin/nvcc -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/TH -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/THC -I:/usr/local/cuda/include -I/home/xiaopeng/miniconda3/envs/pytorch/include/python3.7m -c -c /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/csrc/cuda/mish_kernel.cu -o /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc/cuda/mish_kernel.o -DCUDA_NO_HALF_OPERATORS -DCUDA_NO_HALF_CONVERSIONS -DCUDA_NO_HALF2_OPERATORS --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' --expt-extended-lambda -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_61,code=sm_61 -std=c++14 FAILED: /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc/cuda/mish_kernel.o :/usr/local/cuda/bin/nvcc -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/TH -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/THC -I:/usr/local/cuda/include -I/home/xiaopeng/miniconda3/envs/pytorch/include/python3.7m -c -c /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/csrc/cuda/mish_kernel.cu -o /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc/cuda/mish_kernel.o -DCUDA_NO_HALF_OPERATORS -DCUDA_NO_HALF_CONVERSIONS -DCUDA_NO_HALF2_OPERATORS --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' --expt-extended-lambda -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_61,code=sm_61 -std=c++14 /bin/sh: 1: :/usr/local/cuda/bin/nvcc: not found [2/3] c++ -MMD -MF /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc/cpu/mish_cpu.o.d -pthread -B /home/xiaopeng/miniconda3/envs/pytorch/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/TH -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/THC -I:/usr/local/cuda/include -I/home/xiaopeng/miniconda3/envs/pytorch/include/python3.7m -c -c /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/csrc/cpu/mish_cpu.cpp -o /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc/cpu/mish_cpu.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14 cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ In file included from /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/ATen/Parallel.h:149, from /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/ATen/CPUApplyUtils.h:3, from /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/csrc/cpu/mish_cpu.cpp:3: /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/ATen/ParallelOpenMP.h:84: warning: ignoring #pragma omp parallel [-Wunknown-pragmas] 84 #pragma omp parallel for if ((end - begin) >= grain_size)
[3/3] c++ -MMD -MF /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc/cuda/mish_cuda.o.d -pthread -B /home/xiaopeng/miniconda3/envs/pytorch/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/TH -I/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/THC -I:/usr/local/cuda/include -I/home/xiaopeng/miniconda3/envs/pytorch/include/python3.7m -c -c /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/csrc/cuda/mish_cuda.cpp -o /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/build/temp.linux-x86_64-3.7/csrc/cuda/mish_cuda.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14 cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ In file included from /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/ATen/Parallel.h:149, from /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/utils.h:3, from /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/nn/cloneable.h:5, from /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/nn.h:3, from /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/csrc/api/include/torch/all.h:12, from /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/torch/extension.h:4, from /home/xiaopeng/ScaledYOLOv4-yolov4-csp/mish-cuda/csrc/cuda/mish_cuda.cpp:2: /home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/include/ATen/ParallelOpenMP.h:84: warning: ignoring #pragma omp parallel [-Wunknown-pragmas] 84 #pragma omp parallel for if ((end - begin) >= grain_size) ninja: build stopped: subcommand failed. Traceback (most recent call last): File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1522, in _run_ninja_build env=env) File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/subprocess.py", line 512, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "setup.py", line 29, in cmdclass={'build_ext': BuildExtension}) File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/setuptools/init.py", line 153, in setup return distutils.core.setup(**attrs) File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/distutils/core.py", line 148, in setup dist.run_commands() File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/distutils/dist.py", line 966, in run_commands self.run_command(cmd) File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/distutils/command/build.py", line 135, in run self.run_command(cmd_name) File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 79, in run _build_ext.run(self) File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/distutils/command/build_ext.py", line 340, in run self.build_extensions() File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 653, in build_extensions build_ext.build_extensions(self) File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/distutils/command/build_ext.py", line 449, in build_extensions self._build_extensions_serial() File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/distutils/command/build_ext.py", line 474, in _build_extensions_serial self.build_extension(ext) File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 196, in build_extension _build_ext.build_extension(self, ext) File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/distutils/command/build_ext.py", line 534, in build_extension depends=ext.depends) File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 482, in unix_wrap_ninja_compile with_cuda=with_cuda) File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1238, in _write_ninja_file_and_compile_objects error_prefix='Error compiling objects for extension') File "/home/xiaopeng/miniconda3/envs/pytorch/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1538, in _run_ninja_build raise RuntimeError(message) from e RuntimeError: Error compiling objects for extension `
@trikim 我用的是cuda11.0,ubuntu20.04.两个版本的mish都试了。都不行。 你碰见过这个错误吗 @WongKinYiu @DataXujing @JustinhoCHN
兄弟我和你一样的错误,现在解决了吗?
@LoveMartina pytorh版本问题,需要1.5或者1.4,太新的不行。
修改CUDA_HOME=/usr/local/cuda/bin/nvcc 即可,我也遇到这个问题了,修改了CUDA_HOME就能完成编译了。
也尝试过,也是相同的error,我可不可以在
models/ common.py
中基于Pytorch重新给个Mish激活函数的定义?如下:# no pretrain # from mish_cuda import MishCuda as Mish # pretrain #from mc.build.lib.mish_mish import MishCuda as Mish # 实在装不上mish-cuda,用pytorch自己实现 class Mish(nn.Module): def __init__(self): super().__init__() def forward(self,x): x = x * (torch.tanh(F.softplus(x))) return x
这样我训练是可以正常训练的,但是不确定这个Mish-cuda和Mish激活函数的区别在哪,求大佬答疑解惑!
它可以工作,但不能使用预训练模型
ubuntu16.04, V100 GPU. Python3.7, 在cuda9.0, Pytorch1.3.0的情况下 Mish-cuda是可正常编译安装的,但是此时无法使用amp; CUDA9.2和CUDA10.0,CUDA10.2下均尝试显示安装Mish-cuda报错,大佬们有遇到过这种情况吗?