autumnai / leaf

Open Machine Intelligence Framework for Hackers. (GPU/CPU)
Apache License 2.0
5.56k stars 270 forks source link

cannot compile the example #105

Open jianingy opened 8 years ago

jianingy commented 8 years ago

Hi, all I try to compile and run leaf example with the following command, cargo run --release --no-default-features --features cuda --example benchmarks alexnet but got errors like this

In function `convolution_descriptor::ConvolutionDescriptor::new::hbe3406e228523108khb':
cudnn.0.rs:(.text._ZN22convolution_descriptor21ConvolutionDescriptor3new20hbe3406e228523108khbE+0x29c): undefined reference to `cudnnSetConvolutionNdDescriptor_v3'
cudnn.0.rs:(.text._ZN22convolution_descriptor21ConvolutionDescriptor3new20hbe3406e228523108khbE+0x346): undefined reference to `cudnnSetConvolutionNdDescriptor_v3'
cudnn.0.rs:(.text._ZN22convolution_descriptor21ConvolutionDescriptor3new20hbe3406e228523108khbE+0x3a2): undefined reference to `cudnnSetConvolutionNdDescriptor_v3'

I am using rustc 1.8.0 with cargo 0.10.0.

please give me some hints.

thanks

jakelee8 commented 8 years ago

Did you install Cuda and cudnn?

https://developer.nvidia.com/accelerated-computing-toolkit

jianingy commented 8 years ago

yep, i am sure i've installed them since I can compile and run other applications.

they are located at

/usr/lib/x86_64-linux-gnu/libcudnn.so /usr/lib/x86_64-linux-gnu/libcuda.so

lvitol commented 8 years ago

may be the cudnn version not match, try cudnn v3

jakelee8 commented 8 years ago

This Stack Overflow answer fix that problem for me.

export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/
jakelee8 commented 8 years ago

Though now, I'm running into undefined symbol errors.

note: Undefined symbols for architecture x86_64:
  "_cudnnConvolutionBackwardData_v3", referenced from:
      cudnn::api::convolution::_$LT$impl$u20$API$GT$::convolution_backward_data::he8223ff51775f8a6 in libcudnn-e530283dd2c0d0c1.rlib(cudnn-e530283dd2c0d0c1.0.o)
  "_cudnnConvolutionBackwardFilter_v3", referenced from:
      cudnn::api::convolution::_$LT$impl$u20$API$GT$::convolution_backward_filter::h75fc249aacd45956 in libcudnn-e530283dd2c0d0c1.rlib(cudnn-e530283dd2c0d0c1.0.o)
  "_cudnnSetConvolutionNdDescriptor_v3", referenced from:
      cudnn::convolution_descriptor::ConvolutionDescriptor::new::h06812852cb5d2f0b in libcudnn-e530283dd2c0d0c1.rlib(cudnn-e530283dd2c0d0c1.0.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

OS: Mac OS X 10.11.5

Cargo configuration: native + cuda

[features]
default = ["native", "cuda"]
native = ["leaf/native", "collenchyma/native"]
opencl = ["leaf/opencl", "collenchyma/opencl"]
cuda = ["leaf/cuda", "collenchyma/cuda"]

btw, I had to disable opencl support because the crate uses the -lOpenCL instead of '-framework OpenCL` flag needed on Mac OS.

Edit: there's an issue for this in the examples directory: https://github.com/autumnai/leaf-examples/issues/9