SasView / sasview

Code for the SasView application.
BSD 3-Clause "New" or "Revised" License
50 stars 41 forks source link

OpenCL issue on some platforms - particularly windows with multiple graphic cards #1450

Open RichardHeenan opened 4 years ago

RichardHeenan commented 4 years ago

The logic in the OpenCL Options dialog seems not to work on my machine, resulting in it being unclear whether openCL is on or off, and then calculations of I(Q) failing - see example error mesage below.

My machine has dual NVIDIA CUDA: Quadro K420, so there are boxes for 2 of them, plus "No OpenCL", I'm not convinced that the check box logic works properly when there are three boxes.

The "test" button works, and all models compile OK.

Currently if I select "no OpenCL" and hit fit I get 16:20:05 - INFO: 2020-01-29 16:20:05 16:20:05 - ERROR: Fitting failed: Traceback (most recent call last): File "site-packages\sasview-5.0.1-py3.6-win-amd64.egg\sas\qtgui\Perspectives\Fitting\FitThread.py", line 79, in compute File "site-packages\sasview-5.0.1-py3.6-win-amd64.egg\sas\qtgui\Perspectives\Fitting\FitThread.py", line 19, in map_apply File "site-packages\sasview-5.0.1-py3.6-win-amd64.egg\sas\qtgui\Perspectives\Fitting\FitThread.py", line 16, in map_getattr File "site-packages\sasview-5.0.1-py3.6-win-amd64.egg\sas\sascalc\fit\BumpsFitting.py", line 293, in fit File "site-packages\sasview-5.0.1-py3.6-win-amd64.egg\sas\sascalc\fit\BumpsFitting.py", line 206, in theory File "site-packages\sasview-5.0.1-py3.6-win-amd64.egg\sas\sascalc\fit\BumpsFitting.py", line 196, in _recalculate File "site-packages\sasview-5.0.1-py3.6-win-amd64.egg\sas\sascalc\fit\AbstractFitEngine.py", line 243, in residuals File "C:\sasview501rc\sasmodels\sasviewmodel.py", line 641, in evalDistribution result, = self.calculate_Iq(qdist) File "C:\sasview501rc\sasmodels\sasview_model.py", line 715, in calculate_Iq return self._calculate_Iq(qx, qy) File "C:\sasview501rc\sasmodels\sasview_model.py", line 728, in _calculate_Iq calculator = self._model.make_kernel(q_vectors) File "C:\sasview501rc\sasmodels\product.py", line 346, in make_kernel p_kernel = self.P.make_kernel(q_vectors) File "C:\sasview501rc\sasmodels\kernelcl.py", line 440, in make_kernel return GpuKernel(self, q_vectors) File "C:\sasview501rc\sasmodels\kernelcl.py", line 558, in init self.q_input = GpuInput(q_vectors, dtype) File "C:\sasview501rc\sasmodels\kernelcl.py", line 513, in init env = environment() File "C:\sasview501rc\sasmodels\kernelcl.py", line 181, in environment raise RuntimeError("SAS_OPENCL=None in environment") RuntimeError: SAS_OPENCL=None in environment 16:20:05 - ERROR: SAS_OPENCL=None in environment None

Earlier with OpenCl option on I got ...

File "site-packages\sasview-5.0.1-py3.6-win-amd64.egg\sas\sascalc\fit\AbstractFitEngine.py", line 243, in residuals File "C:\sasview501rc\sasmodels\sasviewmodel.py", line 641, in evalDistribution result, = self.calculate_Iq(qdist) File "C:\sasview501rc\sasmodels\sasview_model.py", line 715, in calculate_Iq return self._calculate_Iq(qx, qy) File "C:\sasview501rc\sasmodels\sasview_model.py", line 742, in _calculate_Iq magnetic=is_magnetic) File "C:\sasview501rc\sasmodels\product.py", line 464, in Iq = self.p_kernel.Fq(p_details, p_values, cutoff, magnetic, er_mode) File "C:\sasview501rc\sasmodels\kernel.py", line 155, in Fq radius_effective_mode) File "C:\sasview501rc\sasmodels\kernelcl.py", line 622, in _call_kernel *kernel_args, wait_for=wait_for)] File "site-packages\pyopencl__init__.py", line 815, in kernel_call File "", line 124, in enqueue_knl_core_shell_sphere_Iq pyopencl._cl.LogicError: when processing argument #4 (1-based): clSetKernelArg failed: INVALID_MEM_OBJECT 16:10:39 - ERROR: when processing argument #4 (1-based): clSetKernelArg failed: INVALID_MEM_OBJECT None

RichardHeenan commented 4 years ago

Having restarted sasview again, despite "No OpenCL" being sel;ected the compiler says 6:22:58 - INFO: --- SasView session started --- 16:22:58 - INFO: Python: 3.6.7 (default, Dec 6 2019, 07:03:06) [MSC v.1900 64 bit (AMD64)] 16:24:25 - INFO: building core_shell_sphere-float32-9CCCF8AB for OpenCL Quadro K420 16:24:49 - INFO: building hardsphere-float64-F2C5DD54 for OpenCL Quadro K420 whixch seems to me to indicate that it is using OpenCL regardless ?

butlerpd commented 4 years ago

moving to 5.0.2 as per today's conversation

RichardHeenan commented 4 years ago

Currently, with e.g. 5.0.1 windows release, though "No OpenCL" is selected, sasview seems to be still using OpenCL. Routine for the check boxes is ...

sas/qtgui/Persepectives/fitting/Ui/GPUOptionsUI.py

OpenCL_2cards

76 tests completed. All tests passed!

Platform Details:

Sasmodels version: 1.0

Platform used: ["Windows", "NDW1501", "10", "10.0.18362", "AMD64", "Intel64 Family 6 Model 63 Stepping 2, GenuineIntel"]

OpenCL driver: single precision: "NVIDIA Corporation, OpenCL 1.2 CUDA 10.2.88, NVIDIA Corporation, Quadro K420, OpenCL 1.2 CUDA" double precision: "same as single precision"

RichardHeenan commented 4 years ago

As mentioned can selected 2 of 3 boxes at once. After several rounds of random clicking of the 3 boxes, I did manage to get it back into genuine "No OpenCL", so the logic is failing somewhere, likely in sas/qtgui/Persepectives/fitting/GPUOptions.py

76 tests completed. All tests passed!

Platform Details:

Sasmodels version: 1.0

Platform used: ["Windows", "NDW1501", "10", "10.0.18362", "AMD64", "Intel64 Family 6 Model 63 Stepping 2, GenuineIntel"]

OpenCL driver: None

butlerpd commented 4 years ago

As per today's conversation am moving this to a 5.0.3 milestone in preparation for a 5.0.2 release.

butlerpd commented 4 years ago

I cannot remember if this has been fixed or not but will move to 5.0.4 for now

butlerpd commented 4 years ago

@RichardHeenan or @piotr? do you know the status of this?

RichardHeenan commented 4 years ago

@RichardHeenan or @piotr? do you know the status of this?

It has not been fixed yet, Paul K said would be tricky as needs a machine (like my pc) with multiple graphics cards.

butlerpd commented 4 years ago

OK ... will retitle the issue then since it is not a 5.0.1 issue (i.e. fixed) but remains a general open Cl issue

lucas-wilkins commented 2 years ago

Does #2164 fix this?

butlerpd commented 2 years ago

2164 moves config to config classes? I'm not sure I understand how that would address the OpenCL not working issue?

lucas-wilkins commented 2 years ago

https://github.com/SasView/sasview/issues/2164 moves config to config classes? I'm not sure I understand how that would address the OpenCL not working issue?

I rewrote the logic in the GPU selection dialogue, and changed how the environment variables get set. It was a big mess before, so perhaps things are better now?