daniilidis-group / neural_renderer

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

Compilation Issues #5

Closed esizikova closed 6 years ago

esizikova commented 6 years ago

I'm getting the following errors compiling this code on OSX High Sierra 10.13.

neural_renderer/cuda/load_textures_cuda.cpp:24:5: error: too many arguments provided to function-like macro invocation
    CHECK_INPUT(image);
    ^
neural_renderer/cuda/load_textures_cuda.cpp:15:24: note: expanded from macro 'CHECK_INPUT'
#define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x)
                       ^
neural_renderer/cuda/load_textures_cuda.cpp:13:53: note: expanded from macro 'CHECK_CUDA'
#define CHECK_CUDA(x) AT_ASSERT(x.type().is_cuda(), #x " must be a CUDA tensor")
                                                    ^
<scratch space>:273:1: note: expanded from here
"image"
^
/Users/lena/anaconda/envs/neuralrender/lib/python2.7/site-packages/torch/lib/include/ATen/Error.h:118:9: note: macro 'AT_ASSERT' defined here
#define AT_ASSERT(cond) \
        ^
neural_renderer/cuda/load_textures_cuda.cpp:24:5: error: use of undeclared identifier 'AT_ASSERT'
    CHECK_INPUT(image);
    ^

I'm using the following command to compile. (I've already installed pytorch)

sudo MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ CFLAGS="-std=c++11 -stdlib=libc++ -mmacosx-version-min=10.9" CUDA_HOME=/usr/local/cuda/ python setup.py install

nkolot commented 6 years ago

I've only tried to compile it using g++ on Ubuntu 16.04, so I can't tell you if it's a clang issue.

Can you try to change AT_ASSERT to AT_CHECK in all 3 .cpp files and see if that resolves the issue? As far as I know AT_ASSERT is deprecated. You can check here for more details. The current PyTorch version that I am using does not have the macro AT_CHECK defined, so I have to use the old syntax.

If that doesn't resolve your issues you might as well comment out these lines because the only thing that they do is checking whether the tensor is contiguous and a CUDA tensor.

esizikova commented 6 years ago

I replaced the AT_ASSERT to AT_CHECK in all three files and was able to compile. Thanks!

czw0078 commented 6 years ago

Just additional comments: PyTorch 0.4.1 supports "AT_CHECK". If you upgraded your PyTorch from 0.4.0 to 0.4.1 (pip install --upgrade torch==0.4.1, for example), then replace them to AT_CHECK.