Compiling mex/mex-CUDA files (Windows)
September 25, 2019 · View on GitHub
If you want to compile mex-CUDA files, make sure to follow the (optional) steps.
What is necessary?
-
Download Visual Studio (VS) IDE.
-
A CUDA-capable GPU (optional).
-
Download CUDA Toolkit (optional).
How to install?
-
Install VS with C++ components.
-
Install CUDA Toolkit with VS integration (default installation) (optional).
How to compile the codes?
-
Open the project/solution on each folder.
-
Change the paths according to your directories, for example:
-
Configuration properties -> VC++ Directories -> Include Directories:
C:\ProgramData\NVIDIA Corporation\CUDA Samples\v10.1\common\inc (optional)
C:\Program Files\MATLAB\R2017b\extern\include
-
Configuration properties -> Linker -> General:
C:\Program Files\MATLAB\R2017b\extern\lib\win64\microsoft
-
How to test?
-
Add the release path on MATLAB, for example:
addpath('C:\DBT-Reconstruction\Functions\Sources\projectionDDb_mex_CUDA\x64\Release')addpath('C:\DBT-Reconstruction\Functions\Sources\backprojectionDDb_mex_CUDA\x64\Release')
-
Or place the .mexw64 files on the Functions folder.
-
Run the main Reconstruction.m file to get the parameters and to load projections.
-
Run the following command to get a simple Back-projection:
dataRecon3d_mex_CUDA = backprojectionDDb_mex_CUDA(double(dataProj),parameter);
-
You should get something like this:
GPU Device 0: "GeForce GTX 1050 Ti" with compute capability 6.1 has 6 Multi-Processors and 4294967296 bytes of global memory
Note: All these codes were developed and tested on:
| Software | Version |
|---|---|
| MATLAB | 2017b |
| Visual Studio IDE | 2019 |
| CUDA Toolkit | 10.1 |
| GPU | GeForce GTX 1050 Ti |
| Windows | 10 |
Compiling mex/mex-CUDA files (Linux)
If you want to compile mex-CUDA files, make sure to follow the (optional) steps.
What is necessary?
-
A CUDA-capable GPU (optional).
-
Download CUDA Toolkit (Tutorial) (optional).
How to compile the codes?
- Run the Compile.m file.
- Make sure to set the variable
cudaPathwith your cuda path (optional).
How to test?
-
The .mexa64 files will be placed on the Functions folder.
-
Run the main Reconstruction.m file to get the parameters and to load projections.
-
Run the following command to get a simple Back-projection:
dataRecon3d_mex_CUDA = backprojectionDDb_mex_CUDA(double(dataProj),parameter);
-
You should get something like this:
GPU Device 0: "GeForce GTX 1050 Ti" with compute capability 6.1 has 6 Multi-Processors and 4294967296 bytes of global memory
Note: All these codes were developed and tested on:
| Software | Version |
|---|---|
| MATLAB | 2017b |
| CUDA Toolkit | 10.1 |
| GPU | GeForce GTX 1050 Ti |
| Ubuntu | 19.04 |
Having problems?
Please report issues here. I also can send you some already compiled mex files.
Laboratory of Computer Vision (Lavi) Department of Electrical and Computer Engineering São Carlos School of Engineering, University of São Paulo São Carlos - Brazil