daniilidis-group / neural_renderer

A PyTorch port of the Neural 3D Mesh Renderer
Other
1.12k stars 248 forks source link

Better Compatibility for __CUDA_ARCH__ for RTX GPUs #62

Open BICHENG opened 4 years ago

BICHENG commented 4 years ago

at rasterize_cuda_kernel.cu you need to change #if CUDA_ARCH < 600 and `defined(CUDA_ARCH)` //blablabla

endif

to

#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 600
#else
static __inline__ __device__ double atomicAdd(double* address, double val) {
    unsigned long long int* address_as_ull = (unsigned long long int*)address;
    unsigned long long int old = *address_as_ull, assumed;
    do {
        assumed = old;
        old = atomicCAS(address_as_ull, assumed,
                __double_as_longlong(val + __longlong_as_double(assumed)));
    // Note: uses integer comparison to avoid hang in case of NaN (since NaN != NaN) } while (assumed != old);
    } while (assumed != old);
    return __longlong_as_double(old);
}
#endif

it will solve setup.py nvcc call errors somehow

b4824583 commented 3 years ago

Thanks God You're a lifesaver

My RTX 2080 can work now

pfvaldez commented 3 years ago

Hello I applied the changes to rasterize_cuda_kernel.cu

Machine specs: RTX-30 cuda 11.2

pip env: torch==1.4.0 torchvision==0.5.0

But I still get this error:

    /usr/local/cuda-11.2/bin/nvcc -I/home/pfvaldez/Development/neural_renderer/venv/lib/python3.8/site-packages/torch/include -I/home/pfvaldez/Development/neural_renderer/venv/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/pfvaldez/Development/neural_renderer/venv/lib/python3.8/site-packages/torch/include/TH -I/home/pfvaldez/Development/neural_renderer/venv/lib/python3.8/site-packages/torch/include/THC -I/usr/local/cuda-11.2/include -I/home/pfvaldez/Development/neural_renderer/venv/include -I/home/pfvaldez/anaconda3/include/python3.8 -c neural_renderer/cuda/load_textures_cuda_kernel.cu -o build/temp.linux-x86_64-3.8/neural_renderer/cuda/load_textures_cuda_kernel.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options '-fPIC' -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=load_textures -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_50,code=sm_50 -gencode=arch=compute_61,code=sm_61 -gencode=arch=compute_30,code=sm_30 -gencode=arch=compute_52,code=sm_52 -gencode=arch=compute_53,code=sm_53 -gencode=arch=compute_35,code=sm_35 -gencode=arch=compute_32,code=sm_32 -gencode=arch=compute_75,code=sm_75 -gencode=arch=compute_62,code=sm_62 -gencode=arch=compute_60,code=sm_60 -gencode=arch=compute_70,code=sm_70 -gencode=arch=compute_72,code=sm_72 -gencode=arch=compute_37,code=sm_37 -std=c++11
    nvcc fatal   : Unsupported gpu architecture 'compute_30'
    error: command '/usr/local/cuda-11.2/bin/nvcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/pfvaldez/Development/neural_renderer/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-283h03zo/neural-renderer-pytorch_ddcda0b2d3c14319913d122830fb84d7/setup.py'"'"'; __file__='"'"'/tmp/pip-install-283h03zo/neural-renderer-pytorch_ddcda0b2d3c14319913d122830fb84d7/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-xbduzdh2/install-record.txt --single-version-externally-managed --compile --install-headers /home/pfvaldez/Development/neural_renderer/venv/include/site/python3.8/neural-renderer-pytorch Check the logs for full command output.