# Tag Info

18

Yes, it is possible! There is a WorframGPULibrary (WGL), which I discover recently. It is undocumented, however there are beautiful examples in $InstallationDirectory/SystemFiles/Links/CUDALink/CSource/ It is similar to LibraryLink, but allows CUDAMemory as an argument. I wrote the code below to call main CUSPARSE routines directly from Mathematica$$C :=... 17 CUDALink allows you to write custom kernels but unfortunately it doesn't allow to use its CUDAMemory in other functions. I found two methods to deal with it. Documented method You can use LibraryLink and call CUDA functions as in a regular CUDA program. For example, you can write something like fourier.cu. Then you can compile it and load "fourier_single" ... 16 The CUDALink package doesn't work right on Linux. For years and years I've been reporting it, they don't fix it. You have to go through some hoops, but when you get it working, it's really sweet! My recommendation: first ensure that your CUDA system itself works, i. e. without M. Compile/run the samples, write your own toy examples, etc. I've been ... 12 Turning the comments into an answer. Making a linear solver work on a GPU is highly nontrivial (it's a task to be assigned to someone who poisened his mother and father), and as far as I can tell, no reasonably working linear solvers for the GPU are shipped with Mathematica. But one can work reasonably well with the built-in tools for SparseArrays. The 5-... 11 Here's how you might approach your problem using direct manipulation of pixel data. First create your graphics: InsertImage = DensityPlot[Sqrt[1 - x^2 - y^2], {x, -1, 1}, {y, -1, 1}, Frame -> False, ColorFunction -> (Opacity[Max[Re[#], 0], GrayLevel[Max[Re[#], 0]]] &), ImageSize -> 20, Background -> Opacity[0, Black]] Now rasterize ... 10 Just for the sake of the argument: Your approach needs about 3.2 seconds for 200 insertions on my machine. Consider this {alpha, col} = Transpose[ Table[{Boole[Im[#] == 0], Max[Re[#], 0]} &@Sqrt[1 - x^2 - y^2], {x, -1, 1, 2/33.}, {y, -1, 1, 2/33.}], {2, 3, 1}]; inset = SetAlphaChannel[Image[col], Image[alpha]]; spiral = Table[{256, 256} + t*{Cos[... 10 Your CUDA paclet is outdated. Updating it with CUDAResourcesInstall[Update -> True] should fix your problems. The output of CUDAResourcesInformation[] reveals that you currently have version 8.0.4.2 installed. The latest version of the CUDA Resources is 10.5.0 (based on its web page). If updating via CUDAResourcesInstall[Update -> True] fails, you ... 10 Tl;dr Version 12 supports CUDA 10.1, which includes support for Turing Architecture. To download the most updated version, even if you’ve just updated & are having trouble: Needs["CUDALink"] CUDAResourcesInstall["<path_to_paclet>", Update->True] As noted by @ilian, version 12 supports Turing chips/architecture. What this means is that GPUs ... 9 I recently encountered a similar problem (CUDAQ[] returning False, CUDADriverVersion[] returning that strange "Mod[100 Revision Number, 1000]"). Here are the steps that finally got the CUDALink back working properly: Uninstalling by executing CUDAResourcesUninstall[] Downloading the proper paclet from http://www.wolfram.com/CUDA/CUDAResources.html ... 9 In the end, in our case, the following allowed us to get CUDA to work. export NVIDIA_DRIVER_LIBRARY_PATH /usr/lib64/libnvidia-tls.so.418.116.00 (adapt to your usage). Then in mathematica Needs["CUDALink"] and CUDAQ[] launches the download of about 4.3 GBytes (!!) of data in .Mathematica (most of it in Paclets/Repository/CUDAResources-Lin64-12.0.... 8 Finally I got a solution. The libcuda.so which is originally from Ubuntu cannot be used. I follow this instructions to install CUDA and it works! 7 This is an extended comment on code style, rather than on your problem. Unfortunately I don't have a CUDA-capable card, so I can't test your actual issue. Generally speaking, however, you will want to try and get away from procedural loops when writing Mathematica code: Alternatives to procedural loops and iterating over lists in Mathematica Why should I ... 7 CUDAImageConvolve is slow due to memory tranfert between the different memories (CPU and GPU). One can decompose the action of CUDAImageConvolve in 6 phases and get de timing of each phase. Here are the results, compared with the CPU ImageConvolve and the straight CUDAImageConvolve : One can see that the convolution alone takes only 16 mS. This ... 7 This is a reply to a question from chris, not a "new" answer. You mean a working example? How about 250 million normally-distributed random numbers, displayed in a histo: Needs["CUDALink"] srcf = FileNameJoin[{$CUDALinkPath, "SupportFiles", "random.cu"}] CUDAInverseCND = CUDAFunctionLoad[{srcf}, "InverseCND", {{_Real, _, "InputOutput"}, _Integer, ...

6

I would use ListCorrelate and rely on Mathematica's internal parallel implementation. Here is your code: part[da_, db_, array_] := Mean @ Flatten @ (array[[span[db],span[da]]]*array[[span[-db],span[-da]]]); span[x_]:=Switch[Sign[x],-1,1;;x-1,0,1;;-1,1,x+1;;-1]; Let's use a smaller array example: array = DeveloperToPackedArray @ RandomChoice[{-1, 1}, {100,...

5

Yes, the nvcc compiler is installed with Mathematica, but you can specify the use of another one. For you the problem seems to be that the architecture sm_61 (this refers to "Compute Capabilities" -> 6.1) is not supported by CUDA 7.5, which is the versions installed with Mathematica 11.0.0. To use sm_61 you have to install CUDA 8 and specify it via "...

5

I got the same error, but only after updating the CUDA Resources to version 10.2.0.3. The problem seems to come about due to the inclusion of -gencode=arch=compute_ 51,code=compute_ 51 in the nvcc command line. This is hardcoded into the definition of CUDALinkNVCCCompilerPrivateResolveCUDAArchitecture when the "CUDAArchitecture" option is Automatic (the ...

5

The maximum dimensionality you can have is 3 and so the maximum number you can pass to get_global_id() is 2. I'd only ever used this in 1Dand 2D before and understand what is going on. However, there appears to be a problem with Mathematica with 3D kernels. Consider this source code for three kernels. They take an input array and output the values of ...

5

There's no fixing for that memory leak problem so far (ver 10.4). Here is the workaround I post in another place https://stackoverflow.com/a/35922539/6046035

5

I found something relevant today (which I don't know if is well-known). If you're using version 9.0.1, then there is a built-in function PacletUninstall[ ], I guess it can be used to properly remove any paclets which are properly installed. And there are more functions like this. Just check ?PacletManager*. I discovered them in the installer cdf for ...

5

Here we go: Upfront, this was a pain as the CUDALink package uses GPUTools, LibraryLink and since we are compiling on our own, CCompilerDriver played its own role. Therefore, it was a lot of code to look at but I believe I found the reason. TL;DR Okay, okay... I believe the main mistake was that by compiling the code with CreateExecutable does name-...

5

This might be a bit faster although it does not look as fancy as output of ContourPlot3D. It needs 4 seconds on my laptop: f = -z + Root[-187.25 + 80.75 x^2 - 4. x^4 - 1. x^6 + 109.119 y - 55.4256 x^2 y + 6.9282 x^4 y - 111.25 y^2 - 24. x^2 y^2 - 3. x^4 y^2 + 55.4256 y^3 + 13.8564 x^2 y^3 - 20. y^4 - 3. x^2 y^4 + 6.9282 y^5 - 1. ...

5

The automatic detection has been improved with a paclet update for version 12.0, so after doing Map[PacletSiteUpdate, PacletSites[]]; PacletUpdate["GPUTools"] Quit it will no longer be necessary to set NVIDIA_DRIVER_LIBRARY_PATH by hand.

4

I encountered the same problem and solved it. You have to check: 1. Your graphics card supports CUDA. 2. CUDA Toolkits and related things have been installed. (from nVidia) 3. CUDA paclet has been installed. (from Wolfram) 4. The C compiler is VS2005, 2008 or 2010. VS2013 is not supported.

4

I have a Dell 17R SE with nVIDIA GeForce GT650M with 3D capabilities and Mathematica 10.3 on Windows 10 64bit. Today I got an answer on my email to support@wolfram.com saying there was no issue on the machine of the support engineer. So I again let Mathematica install the CUDA paclet. The download was extremely slow. But in the end version 10.2.0.3 was ...

4

Since, as you say, CUDAFourier[] does not support the FourierParameters option, you will need to use CUDAInverseFourier[] instead and do a manual renormalization. Observe: Needs["CUDALink`"] BlockRandom[SeedRandom[0]; (* for reproducibility *) lst = RandomComplex[{-9, 9} (1 + I), 32]]; f1 = Sqrt[Length[lst]] CUDAInverseFourier[lst]; f2 = ...

4

After struggling for two days, I finally figure it out minutes after asking for help... so typical :) Nevertheless, I post my solution here in case anyone else gets stuck. The Mathematica documentation ( https://reference.wolfram.com/language/CUDALink/tutorial/Setup.html#271291502 ) claims that the default paths for the path variables are: \$...

3

For the sake of an answer: After several tries I have found that with Mathematica 10.4 and nvidia drivers 367.27 and upgrading to the latest CUDAResources paclet everythig is working ok – Javier Vales Alonso 2 days ago

3

I have managed to get CUDALink working on an ubuntu 14.04 with an NVidia GTX 750 Ti with CUDA 7 toolkit (installed the toolkit following these instructions; http://www.r-tutor.com/gpu-computing/cuda-installation/cuda7.0-ubuntu ). I have never been able to change NVIDIA_DRIVER_LIBRARY_PATH and CUDA_LIBRARY_PATH using env variables and get CUDALink to work. ...

3

I have managed to get CUDALink working on an ubuntu 14.04 with an NVidia GTX 750 Ti with CUDA 7 toolkit (installed the toolkit following these instructions; http://www.r-tutor.com/gpu-computing/cuda-installation/cuda7.0-ubuntu ). I have never been able to change NVIDIA_DRIVER_LIBRARY_PATH and CUDA_LIBRARY_PATH using env variables and get CUDALink to work. ...

Only top voted, non community-wiki answers of a minimum length are eligible