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?

  1. Download Visual Studio (VS) IDE.

  2. A CUDA-capable GPU (optional).

  3. Download CUDA Toolkit (optional).

How to install?

  1. Install VS with C++ components.

  2. Install CUDA Toolkit with VS integration (default installation) (optional).

How to compile the codes?

  1. Open the project/solution on each folder.

  2. 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?

  1. 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')
  2. Or place the .mexw64 files on the Functions folder.

  3. Run the main Reconstruction.m file to get the parameters and to load projections.

  4. Run the following command to get a simple Back-projection:

    • dataRecon3d_mex_CUDA = backprojectionDDb_mex_CUDA(double(dataProj),parameter);
  5. 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:

SoftwareVersion
MATLAB2017b
Visual Studio IDE2019
CUDA Toolkit10.1
GPUGeForce GTX 1050 Ti
Windows10

Compiling mex/mex-CUDA files (Linux)

If you want to compile mex-CUDA files, make sure to follow the (optional) steps.

What is necessary?

  1. A CUDA-capable GPU (optional).

  2. Download CUDA Toolkit (Tutorial) (optional).

How to compile the codes?

  1. Run the Compile.m file.
  2. Make sure to set the variable cudaPath with your cuda path (optional).

How to test?

  1. The .mexa64 files will be placed on the Functions folder.

  2. Run the main Reconstruction.m file to get the parameters and to load projections.

  3. Run the following command to get a simple Back-projection:

    • dataRecon3d_mex_CUDA = backprojectionDDb_mex_CUDA(double(dataProj),parameter);
  4. 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:

SoftwareVersion
MATLAB2017b
CUDA Toolkit10.1
GPUGeForce GTX 1050 Ti
Ubuntu19.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