Let other applications use Matlab's version of the CUDA toolkit

I have an external piece of CUDA code that needs to know the path to the CUDA Toolkit in order to compile. Rather than installing a separate version of the CUDA Toolkit, I would like to use the installation already established on my machine by the Parallel Computing Toolbox (under R2018a). Is that possible, and if so, how do I locate Matlab's copy of the CUDA toolkit?

3 Comments

The version of the CUDA toolkit that used by a particular release of MATLAB is fixed.
@Mohammad. Yes, I know that. Do you know the answer to my question?
I have very similar problem, see here. So far, I only found several unofficial tutorials how to install supported CUDA Toolkit 10.2 on Ubuntu Linux 20.04 (officially supported linux distribution!!!) but without any success. In one case the installation of proper version of GCC broke my whole linux OS functionality??!! The main problem is the GCC compiler version compatibility. CUDA toolkit 10.2 requires GCC 7, but Ubuntu 20.04 has as default GCC 9.
From my point of view is the whole problem very hard to solve to get full CUDA functionality on latest MATLAB versions in general.

Sign in to comment.

 Accepted Answer

There's a difference between the whole toolkit installation and redistributable libraries. If you are compiling things you likely need access to the nvcc compiler and other things like that -- which aren't shipped or installed with MATLAB. On the GPU support by release page, this is called out where it talks about compiling applications. Note that for basic GPU gpuArray type funtions to work, your only need the driver installed -- the SDK is not required. There's more detail in this section:
CUDA Toolkit
If you want to use CUDA kernel objects or use GPU Coder, you must install a CUDA Toolkit. The CUDA Toolkit contains CUDA libraries and tools for compilation.

10 Comments

Thanks, Jason. My ulterior motive for this question is abiding by this requirement from the documentation,
My concern is that, sometimes, NVIDIA will post multiple sub-versions of the same CUDA Toolkit release. So, which sub-version is the right one for the above consistency requirement? For example, there have been 4 patch releases for Toolkit version 9.0. Can I be certain that by installing one or more of these patches to the Toolkit (or declining to), I would not create a conflict with whatever subset of the CUDA Toolkit Matlab installs for itself?
It seems like it would be easiest if Matlab simply installed its own full version of the Toolkit, and then users would just compile with that.
Thanks for your reply, Jason!
To be even more precise, in versions of GPU Coder more recent than the one Matt's using (18a) you won't need to install the CUDA toolkit anymore.
Matt J -- on the GPU support by release page we list down to the minor point version of the toolkit. Is this the patch level you are referring to, or is there something more specific you are looking for?
@Jason,
No, if you go to the NVIDIA toolkit archive you will find 5 downloads for toolkit version 9.0 for windows 10. These appear to be an installer for the initial release of 9.0 and then 4 patches released later, but still affiliated with toolkit version 9.0.
My question is, which of the above must be installed and which must be omitted to be able to safely compile GPU Mex files in R2018a and the following device environment:
CUDADevice with properties:
Name: 'GeForce GTX 1080 Ti'
Index: 1
ComputeCapability: '6.1'
SupportsDouble: 1
DriverVersion: 9
ToolkitVersion: 9
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 1.1811e+10
AvailableMemory: 1.0617e+10
MultiprocessorCount: 28
ClockRateKHz: 1582000
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceSelected: 1
May be, you should ask Nvidia instead of TMW :)
Matt J -- thanks for the link, it was very helpful in illistrating what we can improve. I've filed an enhancement to see if we can at least further document exactly what patch level we are using with each release, and I've included this Answer as a reference.
It looks like the link to "GPU support by release" has gone stale, and I cannot find a similar link for recent Mtlab versions, such as 2023b. Is the material there no longer applicable?
Hi Matt. We greatly simplified the page a few years ago and renamed it GPU Computing Requirements. We were getting a majority of support requests related to GPU support and setup which were significantly confused by the complexity of the table and the mention of CUDA Toolkit version. The driver version number bears no relation to toolkit version, while the vast majority of users don't need to know the toolkit version and it was causing many to mistakenly download and install the toolkit, which can be confusing and problematic. No workflow in Parallel Computing Toolbox now requires the toolkit to be separately installed, not even mexcuda or CUDAKernel. Even GPU Coder no longer requires it for desktop use (i.e. if you are not compiling for embedded hardware).
For the odd edge-case advanced workflow you can still find the toolkit versions listed on the mexcuda example page.
Thanks, but based on what you say, do you think if I do have CUDA Toolkit separately installed, that I should uninstall it? mexcuda is failing for me in R2023b on a laptop with CUDA Toolkit 10.1 installed. I think the PCT in R2023b uses Toolkit 11.8.

mexcuda won't even be using your installed toolkit. If it fails it's probably some other reason. What is the -v output from mexcuda?

Sign in to comment.

More Answers (1)

0: I have no idea about legalities.
1, I found a lot with unix find:
$ find ./ -iname \*cuda\*.so\*
./R2020a/bin/glnxa64/libopencv_cudalegacy.so.3.4
./R2020a/bin/glnxa64/libopencv_cudabgsegm.so.3.4.0
./R2020a/bin/glnxa64/libopencv_cudaobjdetect.so.3.4
./R2020a/bin/glnxa64/libicudata.so.64.2
./R2020a/bin/glnxa64/libopencv_cudafeatures2d.so.3.4.0
./R2020a/bin/glnxa64/libopencv_cudaoptflow.so.3.4.0
./R2020a/bin/glnxa64/libopencv_cudaarithm.so.3.4.0
./R2020a/bin/glnxa64/libopencv_cudafilters.so.3.4
./R2020a/bin/glnxa64/libcudart.so.10.1
./R2020a/bin/glnxa64/libopencv_cudalegacy.so.3.4.0
./R2020a/bin/glnxa64/libopencv_cudaimgproc.so.3.4.0
./R2020a/bin/glnxa64/libopencv_cudaarithm.so.3.4
./R2020a/bin/glnxa64/libopencv_cudabgsegm.so.3.4
./R2020a/bin/glnxa64/libopencv_cudaobjdetect.so.3.4.0
./R2020a/bin/glnxa64/libopencv_cudawarping.so.3.4.0
./R2020a/bin/glnxa64/libopencv_cudawarping.so.3.4
./R2020a/bin/glnxa64/libicudata.so.64
./R2020a/bin/glnxa64/libopencv_cudafeatures2d.so.3.4
./R2020a/bin/glnxa64/libopencv_cudafilters.so.3.4.0
./R2020a/bin/glnxa64/libopencv_cudastereo.so.3.4
./R2020a/bin/glnxa64/libcudart.so.10.1.105
./R2020a/bin/glnxa64/libopencv_cudaoptflow.so.3.4
./R2020a/bin/glnxa64/libopencv_cudastereo.so.3.4.0
./R2020a/bin/glnxa64/libopencv_cudaimgproc.so.3.4
./R2013a/bin/glnxa64/libicudata.so.49
./R2013a/bin/glnxa64/libicudata.so.49.1.2
./R2013a/bin/glnxa64/libcudart.so.5.0.35
./R2013a/bin/glnxa64/libcudart.so.5.0
$ find ./ -iname \*cuda\*.a\*
./R2020a/bin/glnxa64/libcudadevrt.a
./R2020a/bin/glnxa64/libmwgpucoder_cuda.a
./R2020a/sys/cuda/glnxa64/cuda/lib64/libcudart_static.a
If you're not in a Linux/Unix OS, you should be able to find your way to similar lib-files.
HTH

Products

Release

R2018a

Asked:

on 2 Dec 2020

Commented:

on 10 Sep 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!