I've set up pyopencl on my laptop by getting python-pyopencl from multiverse and installing the amd app sdk. To get the Nvidia ICDs I reinstalled the latest Nvidia driver from the driver manager.
My system is a Thinkpad t540p, i7 4700hq, Nvidia gt 730m, 64bit Ubuntu 14.04
To test the opencl installation I ran this pyopencl example: http://wiki.tiker.net/PyOpenCL/Examples/MatrixMultiply
Unfortunately the performance is very bad: Only 2 GFlop/s. Surely the laptop can do better. So I printed the vendor information. It's "GenuineIntel", apparently the kernel is not run on the GPU, but on the CPU. How can I change that ?
It seems like pyopencl doesn't find the GPU.
for dev in ctx.devices:
print dev.vendor
this returns only "GenuineIntel"
The context is created with:
import pyopencl as cl
ctx=cl.create_some_context()
UPDATE:
This seems to be a duplicate of: ERROR: pyopencl: creating context for specific device
There are two issues here.
First, you should specify GPU as the device to execute the kernel on. Replace:
ctx = cl.create_some_context()
with:
platform = cl.get_platforms()
gpus = platform[0].get_devices(device_type=cl.device_type.GPU)
ctx = cl.Context(devices=gpus)
Second, you appear to have Optimus switchable graphics, so the NVIDIA card is actually left in standby and all the graphic tasks are handled by the CPU for powersaving. You will need to activate the discrete GPU for your program by launching it using Bumblebee:
optirun python yourscript.py
Related
I've written code that collects telemetry information from the device and saves it in a .csv file.
However, I'm not able to detect the GPU from the GPUtil:
import GPUtil
GPU = GPUtil.getAvailable()
print(GPU)
print(GPUtil.__version__)
Output:
[]
1.4.0
I didn't find information if it has any relation with the type of architecture of Jetson.
Below is some additional system information:
After a lot of hard work to come up with some solution, I came to some conclusions that I share here.
Reading a little more about GPUtil and analyzing the GPUtil source code here it becomes clear that:
GPUtil is a Python module for getting the GPU status from NVIDA GPUs using nvidia-smi.
Unfortunately, nvidia-smi does not work on NVIDIA Jetson devices (Xavier NX, Nano, AGX Xavier, TX1, TX2).
As my goal was to fetch telemetry data, there were two options:
tegrastats;
jetson-stats.
I found tegrastats options quite limited as tegrastats reports memory and processor usage for Tegra based devices, but it would be necessary to create a bash file, for, for example, automate the process.
You can find the tegrastats utility here.
As my goal was to create a Python script to fetch telemetry data together with other libraries, like cputil, the solution adopted was use the jtop from jetson-stats as a Python library.
jetson-stats is a package for monitoring and control your NVIDIA Jetson [Xavier NX, Nano, AGX Xavier, TX1, TX2] and works with all NVIDIA Jetson ecosystem.
jtop is a system monitoring utility that runs on the terminal and see and control realtime the status of your NVIDIA Jetson. CPU, RAM, GPU status and frequency and other.
To use it, was needed to install jetson-stats:
$ sudo -H pip install -U jetson-stats
To use jtop just type in the terminal the command jtop. The prompt interface will be show.
To import jtop as a Python library just write the following line of code in Python script:
from jtop import jtop
And in my specific case I used the following snippet code:
with jtop() as jetson:
xavier_nx = jetson.stats
CPU_temperature = xavier_nx['Temp CPU']
GPU_temperature = xavier_nx['Temp GPU']
Thermal_temperature = xavier_nx['Temp thermal']
.stats returns a python dict structure, and the available data values are:
time, uptime, jetson_clocks, nvp model, CPU1, CPU2, CPU3, CPU4, CPU5,
CPU6, GPU, MTS FG, MTS BG, RAM, EMC, SWAP, APE, NVENC, NVDEC, NVJPG,
fan, Temp AO, Temp AUX, Temp CPU, Temp GPU, Temp thermal, power cur,
power avg.
Unfortunately jetson-stats doesn't work with Docker. This can be a negative and important point when thinking about using this service in your application.
jetson-stats also works in Docker.
Following the documentation: https://rnext.it/jetson_stats/docker.html
Install jetson-stats on your host
Install jetson-stats on your container as well
Pass to your container /run/jtop.sock:/run/jtop.sock
example of Docker
docker run --rm -it -v /run/jtop.sock:/run/jtop.sock rbonghi/jetson_stats:latest
I hope I have helped you
I've just installed a new GPU (RTX 2070) in my machine alongside the old GPU. I wanted to see if PyTorch picked up it, so following the instructions here: How to check if pytorch is using the GPU?, I ran the following commands (Python3.6.9, Linux Mint Tricia 19.3)
>>> import torch
>>> torch.cuda.is_available()
True
>>> torch.cuda.current_device()
Killed
>>> torch.cuda.get_device_name(0)
Killed
Both of the two Killed processes took some time and one of them froze the machine for half a minute or so. Does anyone have any experience with this? Are there some setup steps I'm missing?
If I understand correctly, you would like to list the available cuda devices. This can be done via nvidia-smi (not a PyTorch function), and both your old GPU and the RTX 2070 should show up, as devices 0 and 1. In PyTorch, if you want to pass data to one specific device, you can do device = torch.device("cuda:0") for GPU 0 and device = torch.device("cuda:1") for GPU 1. While running, you can do nvidia-smi to check the memory usage & running processes for each GPU.
To anyone seeing this down the line, whilst I had the nvidia driver set up I needed to get a couple of other things set up, such as CUDA and the CuDNN toolbox. The best article I found on the subject was https://hackernoon.com/up-and-running-with-ubuntu-nvidia-cuda-cudnn-tensorflow-and-pytorch-a54ec2ec907d.
I am trying openCV+Yolo3. I am using Mac with this config:
MacBook Pro (Retina, 15-inch, Mid - 2015)
Graphics Intel Iris Pro 1536 MB
Update - OS info:
macOS Catalina version 10.15.2
I checked Apple website and it says this MacBook supports openCL 1.2: https://support.apple.com/en-ca/HT202823
My program uses opencv-contrib-python 4.1.2. And the code snippet is:
net = cv2.dnn.readNetFromDarknet(model_configuration, model_weights)
net.setPreferableBackend(cv2.dnn.DNN_BACKEND_OPENCV)
net.setPreferableTarget(cv2.dnn.DNN_TARGET_OPENCL)
I also tried DNN_TARGET_OPENCL_FP16. BTW, I use the common pre-trained yolo3 cfg and weights and coco.names.
The problem is, my program cannot use GPU on my Mac. When I run a video through it, the inference time is 300+ ms per frame and from Activity Monitor I can see that the GPU usage is 0.0% while CPU is 70%+. I don't know why I can't use GPU via openGL on the Mac. Is there any trick I miss?
I have a python file which uses tensorflow GPU in it. It uses GPU when i run the file from console using python MyFile.py.
However, when i convert it into exe using pyinstaller, it converts and runs successfully, But it does not use GPU anymore when i run the exe. This happens on a system which was not used for developing MyFile.py. Checking on the same system which was used in development, it uses just 40-50% GPU, which was 90% if i run the python script.
My application even has a small UI made using tkinter.
Though application runs fine on CPU, It is incredibly slow. (I am not using --one-file flag in pyinstaller.) Although having GPU, The application is not using it.
My questions are:
How do I overcome this issue? Do I need to install any CUDA or CuDnn toolkits in my Destination computer?
(Once the main question is solved) Can i use 1050ti in development and 2080ti in destination computer, if the CuDnn and CUDA versions are the same?
Tensorflow Version : 1.14.0 (I know 2.x is out there, but this works perfectly fine for me.)
GPU : GeForce GTX 1050 ti ( In development as well as deployment.)
CUDA Toolkit : 10.0
CuDnn : v7.6.2 for cuda 10.0
pyinstaller version : 3.5
Python version : 3.6.5
As I asnwered also here, according to the GitHub issues in the official repository (here and here for example) CUDA libraries are usually dynamically loaded at run-time and not at link-time, so they are typically not included in the final exe file (or folder) with the result that the generated exe file won't work on a machine without CUDA installed. The solution (please refer to the linked issues too) is to put the DLLs necessary to run the exe in its dist folder (if generated without the --onefile option) or install the CUDA runtime on the target machine.
My system is ubuntu 16.04 version my laptop is dell Inspiron-5521 and it has intel graphic card but tensorflow needs nvidia graphics for cuda support.
Is there any way where i can run tensorflow with GPU(with CPU is working) on intel graphics.
During installation of tensorflow-gpu i have no error when i import i get
"
Failed to load the native TensorFlow runtime
."
Did some digging then found to install cuda downloaded the "cuda_9.1.85_387.26_linux.run" file but faces issues while running it
"Detected 4 CPUs online; setting concurrency level to 4.
The file '/tmp/.X0-lock' exists and appears to contain the process ID
'1033' of a runnning X server.
It appears that an X server is running. Please exit X before
installation. If you're sure that X is not running, but are getting
this error, please delete any X lock files in /tmp."
Deleted files from tmp folder and tried still same issue.
To run tensorflow-gpu you need nvidia card. You'll need to stick to running normal tensorflow on CPU.
Is Intel based graphic card compatible with tensorflow/GPU?
Tensorflow does not support OpenCL API that you can use with Intel or AMD, only CUDA. CUDA is a proprietary NVidia technology that only works with NVidia GPUs.
You may like to search for machine learning frameworks that utilise OpenCL, but I only find some niche projects at the moment.
I had to switch from AMD to NVidia to be able to run Tensorflow calculations on GPU.