0

I see on the nvidia documentation that thrust has been included with the cuda-toolkit for a while, but it simply does not work anymore. I am looking for instructions that will allow me to run the following example after installing cuda. I will install any version of cuda and any other libraries that I need to install for thrust to work. Save the code below to the file "version.cu"

#include <thrust/version.h>
#include <iostream>
int main(void)
{
  int major = THRUST_MAJOR_VERSION;
  int minor = THRUST_MINOR_VERSION;

  std::cout &lt;&lt; &quot;Thrust v&quot; &lt;&lt; major &lt;&lt; &quot;.&quot; &lt;&lt; minor &lt;&lt; std::endl;

  return 0;
}

If it helps, the code came from the following site: https://github.com/thrust/thrust/wiki/Quick-Start-Guide

Edit: Adding information @d4rk4ng31 lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 18.04.4 LTS Release: 18.04 Codename: bionic

Edit: After getting help from @d4rk4ng31, I now have the ability to use the thrust library. The reason I had so many problems is because of cuda 10.2 and not understanding how to properly remove cuda 10.2. The first step in fixing my problem was to remove cuda 10.2. This was done using a trial and error method of trying to remove all the dependancies with cuda 10.2. The following is some code showing how to remove cuda 10.2 or any other version of cuda for that matter

Start by removing cuda itself: sudo dpkg -r cuda-10-2 (Reading database ... 196295 files and directories currently installed.) Removing cuda-10-2 (10.2.89-1) ...

Now call autoremove and look for packages with unmet dependencies. The examples here are 'cuda-visual-tools-10-2', 'cuda-samples-10-2', 'cuda-visual-tools-10-2'. You will need to remove all three, but there could be more.

sudo apt autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 cuda-libraries-dev-10-2 : Depends: libcublas-dev (>= 10.2.2.89) but it is not installed
 cuda-samples-10-2 : Depends: libcublas-dev (>= 10.2.2.89) but it is not installed
 cuda-visual-tools-10-2 : Depends: libcublas-dev (>= 10.2.2.89) but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

For example, let's try to remove 'cuda-samples-10-2'

sudo dpkg -r cuda-samples-10-2 
  dpkg: dependency problems prevent removal of cuda-samples-10-2:
   cuda-documentation-10-2 depends on cuda-samples-10-2.

dpkg: error processing package cuda-samples-10-2 (--remove): dependency problems - not removing Errors were encountered while processing: cuda-samples-10-2

Looks like 'cuda-documentation-10-2' requires 'cuda-samples-10-2' so we will need to remove 'cuda-documentation-10-2' first.

sudo dpkg -r cuda-documentation-10-2 
(Reading database ... 196286 files and directories currently installed.)
Removing cuda-documentation-10-2 (10.2.89-1) ...

It worked so now we can try 'cuda-samples-10-2' again

sudo dpkg -r cuda-samples-10-2 
(Reading database ... 190931 files and directories currently installed.)
Removing cuda-samples-10-2 (10.2.89-1) ...

Go ahead and call sudo apt autoremove again. For me it said that I still needed to remove cuda-visual-tools-10-2. Using the process above with sudo dkpg -r, con

tinue to remove packages until sudo apt autoremove actually completes without error.

this is an example of what you should see.

sudo apt autoremove
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 6 not upgraded.

At this point I went ahead and ran sudo apt update and sudo apt upgrade but i dont really know if it was needed or not.

Now, in order to complete the new install for cuda I followed directions on another question from @N0rbert located here How do I Install CUDA on Ubuntu 18.04?.

I am going to re-post N0rbert's answer for installing thrust here for convenience.

In a terminal, type:

sudo add-apt-repository ppa:graphics-drivers/ppa

sudo apt update

sudo ubuntu-drivers autoinstall

reboot

sudo apt install nvidia-cuda-toolkit gcc-6

nvcc --version

The 'nvcc --version` should show the following

nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85

Now create the thrust file from the beginning of this post to try out. I am going to call this example code file "version.cu". For convenience here is the link to the thrust repo:https://github.com/thrust/thrust/wiki/Quick-Start-Guide

in the terminal type:

nvcc version.cu -o version

Now type

./version

and you should see this or something similar based on your version of thrust:

Thrust v1.9

0 Answers0