Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

/usr/bin/ld: cannot find -lcudart

Tags:

cuda

nvcc

I'm getting the following message while trying to compile a CUDA program:

/usr/bin/ld: cannot find -lcudart

Never got this kind of error before. Is it any problem with my PATH?

Here's the compile command:

gfortran -g -O2 -ffree-line-length-none -I../shared/ -o ../../bin/xspecfem3D ../../obj/spec/program_specfem3D.o ../../obj/spec/specfem3D_par.o ../../obj/spec/PML_init.o ../../obj/spec/compute_boundary_kernel.o ../../obj/spec/compute_kernels.o ../../obj/spec/compute_forces_acoustic.o ../../obj/spec/compute_forces_acoustic_pot.o ../../obj/spec/compute_forces_acoustic_PML.o ../../obj/spec/compute_forces_elastic.o ../../obj/spec/compute_forces_elastic_Dev.o ../../obj/spec/compute_forces_elastic_noDev.o ../../obj/spec/compute_forces_elastic_Dev_openmp.o ../../obj/spec/compute_add_sources_acoustic.o ../../obj/spec/compute_add_sources_elastic.o ../../obj/spec/compute_coupling_acoustic_el.o ../../obj/spec/compute_coupling_elastic_ac.o ../../obj/spec/compute_stacey_acoustic.o ../../obj/spec/compute_stacey_elastic.o ../../obj/spec/compute_gradient.o ../../obj/spec/compute_interpolated_dva.o ../../obj/spec/initialize_simulation.o ../../obj/spec/read_mesh_databases.o ../../obj/spec/setup_GLL_points.o ../../obj/spec/write_movie_output.o ../../obj/spec/create_color_image.o ../../obj/spec/write_seismograms.o ../../obj/spec/write_output_ASCII.o ../../obj/spec/detect_mesh_surfaces.o ../../obj/spec/setup_movie_meshes.o ../../obj/spec/read_topography_bathymetry.o ../../obj/spec/setup_sources_receivers.o ../../obj/spec/prepare_timerun.o ../../obj/spec/iterate_time.o ../../obj/spec/finalize_simulation.o ../../obj/spec/save_adjoint_kernels.o ../../obj/spec/specfem3D.o ../../obj/spec/assemble_MPI_vector.o ../../obj/spec/make_gravity.o ../../obj/spec/noise_tomography.o ../../lib/libspecfem.a ../../obj/spec/check_fields_cuda.cuda.o ../../obj/spec/compute_add_sources_acoustic_cuda.cuda.o ../../obj/spec/compute_add_sources_elastic_cuda.cuda.o ../../obj/spec/compute_coupling_cuda.cuda.o ../../obj/spec/compute_forces_acoustic_cuda.cuda.o ../../obj/spec/compute_forces_elastic_cuda.cuda.o ../../obj/spec/compute_kernels_cuda.cuda.o ../../obj/spec/compute_stacey_acoustic_cuda.cuda.o ../../obj/spec/compute_stacey_elastic_cuda.cuda.o ../../obj/spec/it_update_displacement_cuda.cuda.o ../../obj/spec/noise_tomography_cuda.cuda.o ../../obj/spec/prepare_mesh_constants_cuda.cuda.o ../../obj/spec/transfer_fields_cuda.cuda.o ../../obj/spec/write_seismograms_cuda.cuda.o ../../obj/spec/save_and_compare_cpu_vs_gpu.cudacc.o ../../obj/spec/serial.o -lcuda -lcudart -lcublas

/usr/bin/ld: cannot find -lcudart

collect2: ld returned 1 exit status

Edit:

I've changed the linkage command to

gfortran -g -O2 -ffree-line-length-none -I../shared/ -L$CUDA_HOME/lib [rest follows]

And all my PATHs seems to be OK, but I'm still having the same error.

Edit2:

The error was that the code I was trying to compile was in 64bit, so I needed to give the path a diferent set of .so's , which are located on

/usr/local/cuda/lib64

Now the compilation ran fine ans without any problems.

like image 968
GennSev Avatar asked Mar 09 '12 12:03

GennSev


People also ask

How do you fix usr bin Ld Cannot find?

To resolve this problem, you should either provide the library file ( lib{nameOfTheLibrary}. so ) in those search paths or use -L command option. -L{path} tells the g++ (actually ld ) to find library files in path {path} in addition to default paths.

What does usr bin Ld do?

The ld command verifies the command-line arguments and calls the binder (by default the /usr/ccs/bin/bind file), passing a generated list of binder subcommands. The binder program actually links the files. Although the binder is usually called by the ld command, you can start the binder directly.


2 Answers

You are not specifying the location of the CUDA libraries to the linker, that is why the linkage is failing. nvcc is "automagically" configured to find the CUDA runtime library components, but if you are linking with a host compiler directly, you will need to explicitly specify their location to the compiler. Try changing the linkage command to this:

gfortran -g -O2 -ffree-line-length-none -I../shared/ -L$CUDA_HOME/lib [rest follows]

where CUDA_HOME denotes the path where the CUDA toolkit is installed. Typically this is /usr/local/cuda on linux and OS X systems. You will then need to make sure LD_LIBRARY_PATH contains an entry for $CUDA_HOME/lib so that the executable will dynamically load the required CUDA libraries at runtime.

EDIT:

Also see this

like image 120
talonmies Avatar answered Sep 19 '22 05:09

talonmies


I fixed this! Go to your makefile and change /usr/local/cuda/ to /usr/local/cuda-7.0 (if that's what you got) It worked for me

like image 29
Antony Savvidi Avatar answered Sep 18 '22 05:09

Antony Savvidi