CERN / TIGRE

TIGRE: Tomographic Iterative GPU-based Reconstruction Toolbox
BSD 3-Clause "New" or "Revised" License
529 stars 180 forks source link

Error Compiling in Matlab #503

Closed tamish2 closed 7 months ago

tamish2 commented 8 months ago

Expected Behavior

Compile code successfully

Actual Behavior

Renamed options file '/home-local/user1/.matlab/R2023a/mex_CUDA_glnxa64.xml' to '/home-local/user1/.matlab/R2023a/mex_CUDA_glnxa64_backup.xml'. MEX configured to use 'nvcc' for CUDA language compilation. Compiling TIGRE source... This may take a couple of minutes.... Warning: Selected compiler 'nvcc' is not supported and no other supported compiler was found. For options, visit https://www.mathworks.com/support/compilers.

In Compile (line 94) Renamed options file '/home-local/user1/.matlab/R2023a/mex_CUDA_glnxa64.xml' to '/home-local/user1/.matlab/R2023a/mex_CUDA_glnxa64_backup.xml'. Building with 'nvcc'. /home-local/user1/TIGRE/MATLAB/../Common/CUDA/ray_interpolated_projection_parallel.cu(235): warning #177-D: variable "divangle" was declared but never referenced

/home-local/user1/TIGRE/MATLAB/../Common/CUDA/Siddon_projection_parallel.cu(159): warning #177-D: variable "azm" was declared but never referenced /home-local/user1/TIGRE/MATLAB/../Common/CUDA/Siddon_projection_parallel.cu(160): warning #177-D: variable "azM" was declared but never referenced /home-local/user1/TIGRE/MATLAB/../Common/CUDA/Siddon_projection_parallel.cu(317): warning #177-D: variable "divangle" was declared but never referenced

/home-local/user1/TIGRE/MATLAB/../Common/CUDA/GpuIds.cpp: In member function ‘void GpuIds::SetAllGpus(int)’: /home-local/user1/TIGRE/MATLAB/../Common/CUDA/GpuIds.cpp:44:21: warning: ignoring return value of ‘void malloc(size_t)’, declared with attribute warn_unused_result [-Wunused-result] 44 | (int)malloc(iTotalDeviceCount*sizeof(int)); | ~~^~~~~~~

Error using mex /usr/bin/ld: cannot find -lcudart: No such file or directory collect2: error: ld returned 1 exit status

Error in Compile (line 94) mex('-largeArrayDims', '-I"../Common"', './Utilities/cuda_interface/Ax_mex.cpp', '../Common/CUDA/ray_interpolated_projection.cu', '../Common/CUDA/Siddon_projection.cu', '../Common/CUDA/ray_interpolated_projection_parallel.cu', '../Common/CUDA/Siddon_projection_parallel.cu', '../Common/CUDA/GpuIds.cpp', '-outdir', outdir, FLAGS)

Code to reproduce the problem (If applicable)

Just compiling the code

Specifications

AnderBiguri commented 8 months ago

Hi @tamish2 . I've never seen this particular error, but it seems to say that it can't find -lcudart, i.e. the libraru of CUDA run time. This seems to suggest that the compiler does not know where nvcc is, in particular the libraries of CUDA. Have you perhaps installed somewhere strange?

tamish2 commented 8 months ago

These are my paths export LD_LIBRARY_PATH=/usr/local/cuda-11.5/lib64:$LD_LIBRARY_PATH export PATH=/usr/local/cuda-11.5/bin:$PATH export MW_NVCC_PATH=/usr/local/cuda-11.5/bin/nvcc

Do I need to change anything in the xml files

AnderBiguri commented 8 months ago

@tamish2 not in theory, no. Do you have the symlink for /usr/loca/cuda ?

AnderBiguri commented 7 months ago

Closing it due to inactivity, feel free to open it again if you still have issues

Shi5013 commented 7 months ago

Hi @AnderBiguri ,I also met a question when I compiled Compile.m `Error using mex In file included from /usr/include/c++/11/cstdint:35, from /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:9: /usr/include/c++/11/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options. 32 | #error This file requires compiler and library support \ | ^~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp: In function €˜int cReadXim(char, XimPara, int)€™: /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:231:25: error: €˜uint8_t€™ was not declared in this scope; did you mean €˜uint8_T€™? 231 | uint8_t buffer8 = new uint8_t[XimStr->ImgWidth XimStr->ImgHeight]; | ^~~ | uint8_T /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:231:34: error: €˜buffer8€™ was not declared in this scope 231 | uint8_t buffer8 = new uint8_t[XimStr->ImgWidth XimStr->ImgHeight]; | ^~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:231:48: error: €˜uint8_t€™ does not name a type; did you mean €˜uint8_T€™? 231 | uint8_t buffer8 = new uint8_t[XimStr->ImgWidth XimStr->ImgHeight]; | ^~~ | uint8_T /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:242:25: error: €˜uint16_t€™ was not declared in this scope; did you mean €˜uint16_T€™? 242 | uint16_t buffer16 = new uint16_t[XimStr->ImgWidth XimStr->ImgHeight]; | ^~~~ | uint16_T /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:242:35: error: €˜buffer16€™ was not declared in this scope 242 | uint16_t buffer16 = new uint16_t[XimStr->ImgWidth XimStr->ImgHeight]; | ^~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:242:50: error: €˜uint16_t€™ does not name a type; did you mean €˜uint16_T€™? 242 | uint16_t buffer16 = new uint16_t[XimStr->ImgWidth XimStr->ImgHeight]; | ^~~~ | uint16_T /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp: In function €˜void mexFunction(int, mxArray, int, const mxArray)€™: /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:62:14: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 62 | fread(&(para->ImgWidth), sizeof(int32_T), 1, fid); | ~^~~~~~~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:63:14: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 63 | fread(&(para->ImgHeight), sizeof(int32_T), 1, fid); | ~^~~~~~~~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp: In function €˜int cReadXim(char, XimPara, int)€™: /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:120:14: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 120 | fread(&(XimStr->ImgWidth), sizeof(int32_T), 1, fid); | ~^~~~~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:121:14: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 121 | fread(&(XimStr->ImgHeight), sizeof(int32_T), 1, fid); | ~^~~~~~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:128:14: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 128 | fread(&(XimStr->BytesPerPixel), sizeof(int32_T), 1, fid); | ~^~~~~~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:129:14: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 129 | fread(&(XimStr->Compression_Indicator), sizeof(int32_T), 1, fid); | ~^~~~~~~~~~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:135:22: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 135 | fread(&LookUpTableSize, sizeof(int), 1, fid); | ~^~~~~~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:146:30: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 146 | fread(&tmp, 1, 1, fid); | ~^~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:178:22: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 178 | fread(XimImg, sizeof(int32_T), (XimStr->ImgWidth) + 1, fid); | ~^~~~~~~~~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:195:38: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 195 | fread(&tmp8, sizeof(int8_T), 1, fid); | ~^~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:200:38: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 200 | fread(&tmp16, sizeof(int16_T), 1, fid); | ~^~~~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:205:38: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 205 | fread(&tmp32, sizeof(int32_T), 1, fid); | ~^~~~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:225:22: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 225 | fread(&BufferSize, sizeof(int), 1, fid); | ~^~~~~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:253:30: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 253 | fread(XimImg, sizeof(int), BufferSize / 4, fid); | ~^~~~~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:263:14: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 263 | fread(&tmp, sizeof(int), 1, fid); | ~^~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:271:14: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 271 | fread(&nProperties, sizeof(int), 1, fid); | ~^~~~~~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:282:30: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 282 | fread(&pName_len, sizeof(int), 1, fid); | ~^~~~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:284:30: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 284 | fread(pName, sizeof(char) pName_len, 1, fid); | ~^~~~~~~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:286:30: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 286 | fread(&pType, sizeof(int), 1, fid); | ~^~~~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:293:38: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 293 | fread(&(XimStr->GantryRtn), sizeof(double), 1, fid); | ~^~~~~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:299:38: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 299 | fread(&(XimStr->KVNormChamber), sizeof(int), 1, fid); | ~^~~~~~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:319:46: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 319 | fread(&skiplen, sizeof(int), 1, fid); | ~^~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:326:46: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 326 | fread(&skiplen, sizeof(int), 1, fid); | ~^~~~~~~ /media/user_gou/Elements/Shi/4DCBCTReconstruction/4DCBCTReconstruction/TIGRE-master/MATLAB/./Utilities/IO/VarianCBCT/mexReadXim.cpp:333:46: warning: ignoring return value of €˜size_t fread(void, size_t, size_t, FILE*)€™ declared with attribute €˜warn_unused_result€™ [-Wunused-result] 333 | fread(&skiplen, sizeof(int), 1, fid); | ~^~~~~~~

Error in Compile (line 108) mex('-largeArrayDims', './Utilities/IO/VarianCBCT/mexReadXim.cpp', '../Common/CUDA/gpuUtils.cu', '-outdir', outdir, FLAGS)`

image

My Path

image

Shi5013 commented 7 months ago

Additionally, when I download the Tigre files, where should I place this folder? Can I directly place it in the directory of my code files?

AnderBiguri commented 7 months ago

Hi @Shi5013 , The first issue is on #470 . The VarianDataLoader from MATLAB doesn't seem to be compiling in linux. The rest of the toolbox should work, hopefully. You can comment this line of code to remove it if you are not using Varian CBCT data: https://github.com/CERN/TIGRE/blob/master/MATLAB/Compile.m#L102

Second, you can put TIGRE wherever you want. For MATLAB, it doesn't matter. I see you are also using python, so if you were to install it using the python scripts, it would install in your enviroment (e.g. conda).

Shi5013 commented 7 months ago

Thank you for your reply @AnderBiguri ! But However, it seems like the error is occurring at line 108 of my program, not line 102. Can I directly comment out line 108? Will this affect my usage of the toolbox?

The first time I ran it, there was an error at line 102, but after modifying the preceding FLAGS, the error no longer occurs at line 102.


if disable_pinned

    FLAGS=['-DNO_PINNED_MEMORY -std=c++11'];  % add -std=c++11 option

else

    FLAGS=['-DNO_FLAGS -std=c++11'];  % add -std=c++11 option

end
AnderBiguri commented 7 months ago

@Shi5013 you may be using an older version of TIGRE then. As you can see however, its the same line, i.e. the one that compiles mexReadXim.cpp. Please refer to either the current status of TIGRE, or give me the line, not the number, of older versions.

Currently line 108 is for the compilation in 32 bit CPUs, and reads: mex( './Utilities/cuda_interface/minTV.cpp', '../Common/CUDA/POCS_TV.cu', '../Common/CUDA/GpuIds.cpp', '../Common/CUDA/gpuUtils.cu', '-outdir', outdir, FLAGS)

Shi5013 commented 7 months ago

As you said, I might have downloaded an old version. My line 108 is:

mex('-largeArrayDims', './Utilities/IO/VarianCBCT/mexReadXim.cpp', '../Common/CUDA/[gpuUtils.cu](http://gpuutils.cu/)', '-outdir', outdir, FLAGS)

I'll redownload the latest version and try again.

Thanks!