mumax / 3

GPU-accelerated micromagnetic simulator
Other
450 stars 150 forks source link

Install Mumax3 with CUDA not in default directory #212

Closed Crolan closed 5 years ago

Crolan commented 5 years ago

Hi, I'm installing mumax on a server which CUDA is not installed at the default location. If you have any direct solutions, please skip all the following redundancy.

I tried add the CUDA path to both /cuda/curand/cgoflags.go and /cuda/cu/cgoflags.go, and I got the following message after "go install":


//# github.com/mumax/3/cuda/curand
../../cuda/curand/generator.go:3:20: fatal error: curand.h: No such file or directory
 //#include <curand.h>
                    ^
compilation terminated.
//# github.com/mumax/3/cuda/cu
/opt/apps/gcc/5.4.0/bin/ld: cannot find -lcuda
/opt/apps/gcc/5.4.0/bin/ld: cannot find -lcuda
collect2: error: ld returned 1 exit status
......

To deal with the curand.h issue, I copied the curand.h file from the cuda folder to /cuda/curand, the curand.h error disappeared, but the other messages left as:


/# github.com/mumax/3/cuda/cu
/opt/apps/gcc/5.4.0/bin/ld: cannot find -lcuda
/opt/apps/gcc/5.4.0/bin/ld: cannot find -lcuda
collect2: error: ld returned 1 exit status
/# github.com/mumax/3/cuda/cu
cgo-gcc-prolog: In function ‘_cgo_208fe6b3463b_Cfunc_cuDeviceComputeCapability’:
cgo-gcc-prolog:47:2: warning: ‘cuDeviceComputeCapability’ is deprecated [-Wdeprecated-declarations]
In file included from ../../cuda/cu/device.go:5:0:
/opt/apps/cuda/9.2/include/cuda.h:2531:36: note: declared here
 __CUDA_DEPRECATED CUresult CUDAAPI cuDeviceComputeCapability(int *major, int *minor, CUdevice dev);
                                    ^
cgo-gcc-prolog: In function ‘_cgo_208fe6b3463b_Cfunc_cuDeviceGetProperties’:
cgo-gcc-prolog:150:2: warning: ‘cuDeviceGetProperties’ is deprecated [-Wdeprecated-declarations]
In file included from ../../cuda/cu/device.go:5:0:
/opt/apps/cuda/9.2/include/cuda.h:2497:36: note: declared here
 __CUDA_DEPRECATED CUresult CUDAAPI cuDeviceGetProperties(CUdevprop *prop, CUdevice dev);

I got no clue since here. What other steps should I have before I can finish the installation?

This problem seems related to another open issue: https://github.com/mumax/3/issues/180#issue-329837331

Thanks in advance.

barnex commented 5 years ago

Is it possible that only added header locations to CFLAGS, but no library locations to LDFLAGS? Seems like the linker cannot find libcuda.so.

Can you post the changes you made?

Crolan commented 5 years ago

Is it possible that only added header locations to CFLAGS, but no library locations to LDFLAGS? Seems like the linker cannot find libcuda.so.

Can you post the changes you made?

Hi barnex,

I've changed the following bold parts:

package curand

// This file provides CGO flags to find CUDA libraries and headers.

//#cgo LDFLAGS:-lcurand
//
////default location:

//#cgo LDFLAGS:-L/opt/apps/cuda/9.2/lib64 -L/opt/apps/cuda/9.2/lib //#cgo CFLAGS: -I/opt/apps/cuda/9.2/include

//
////default location if not properly symlinked:
...

and

package cu

// This file provides CGO flags to find CUDA libraries and headers.

//#cgo LDFLAGS:-lcuda
//
////default location:

//#cgo LDFLAGS:-L/opt/apps/cuda/9.2/lib64 -L/opt/apps/cuda/9.2/lib //#cgo CFLAGS: -I/opt/apps/cuda/9.2/include/

//
////default location if not properly symlinked:
...

Thank you and let me know if you need any further information.

barnex commented 5 years ago

That looks reasonable. Do any of the directories under LDPATH contain libcuda.so?

On Mon 3 Dec 2018, 23:55 Crolan, notifications@github.com wrote:

Is it possible that only added header locations to CFLAGS, but no library locations to LDFLAGS? Seems like the linker cannot find libcuda.so.

Can you post the changes you made?

Hi barnex,

I've changed the following bold parts:

package curand

// This file provides CGO flags to find CUDA libraries and headers.

//#cgo LDFLAGS:-lcurand // ////default location:

//#cgo LDFLAGS:-L/opt/apps/cuda/9.2/lib64 -L/opt/apps/cuda/9.2/lib //#cgo CFLAGS: -I/opt/apps/cuda/9.2/include

// ////default location if not properly symlinked: ...

and

package cu

// This file provides CGO flags to find CUDA libraries and headers.

//#cgo LDFLAGS:-lcuda // ////default location:

//#cgo LDFLAGS:-L/opt/apps/cuda/9.2/lib64 -L/opt/apps/cuda/9.2/lib //#cgo CFLAGS: -I/opt/apps/cuda/9.2/include/

// ////default location if not properly symlinked: ...

Thank you and let me know if you need any further information.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/mumax/3/issues/212#issuecomment-443916000, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZ3AnzG7w-CAuP4A4ejRVLh7COQdHhDks5u1bndgaJpZM4Y9Qk- .

Crolan commented 5 years ago

That looks reasonable. Do any of the directories under LDPATH contain libcuda.so? On Mon 3 Dec 2018, 23:55 Crolan, @.**> wrote: Is it possible that only added header locations to CFLAGS, but no library locations to LDFLAGS? Seems like the linker cannot find libcuda.so. Can you post the changes you made? Hi barnex, I've changed the following bold parts: package curand // This file provides CGO flags to find CUDA libraries and headers. //#cgo LDFLAGS:-lcurand // ////default location: //#cgo LDFLAGS:-L/opt/apps/cuda/9.2/lib64 -L/opt/apps/cuda/9.2/lib //#cgo CFLAGS: -I/opt/apps/cuda/9.2/include // ////default location if not properly symlinked: ... and package cu // This file provides CGO flags to find CUDA libraries and headers. //#cgo LDFLAGS:-lcuda // ////default location: //#cgo LDFLAGS:-L/opt/apps/cuda/9.2/lib64 -L/opt/apps/cuda/9.2/lib //#cgo CFLAGS: -I/opt/apps/cuda/9.2/include/* // ////default location if not properly symlinked: ... Thank you and let me know if you need any further information. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#212 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZ3AnzG7w-CAuP4A4ejRVLh7COQdHhDks5u1bndgaJpZM4Y9Qk- .

I cannot find the libcuda.so file right at the LDPATH directory which is /opt/apps/cuda/9.2/lib64, but there is a sub-folder /opt/apps/cuda/9.2/lib64/stubs that do have the libcuda.so file. Should that work? or I need to make changes?

Thanks,

Crolan commented 5 years ago

It seems like that this issue is due to a problem of the nvidia driver, and solved through reinstall and redirect. Thanks for all the helpful suggestions.