Changeset 8479735 in sasview for src


Ignore:
Timestamp:
Oct 31, 2018 6:34:14 AM (6 years ago)
Author:
Piotr Rozyczko <piotr.rozyczko@…>
Branches:
ESS_GUI, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc
Children:
671d2fc8
Parents:
04e1c80
Message:

Updates to the GPU options panel after PR 191 in master.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Perspectives/Fitting/GPUOptions.py

    rdb05c44 r8479735  
    22import os 
    33import sys 
    4 import sasmodels 
    54import json 
    65import platform 
    76import webbrowser 
     7import logging 
     8 
     9import sasmodels 
     10import sasmodels.model_test 
     11import sasmodels.kernelcl 
    812 
    913import sas.qtgui.Utilities.GuiUtils as GuiUtils 
     
    2630        return QtWidgets.QApplication.translate(context, text, disambig) 
    2731 
     32logger = logging.getLogger(__name__) 
    2833 
    2934class GPUOptions(QtWidgets.QDialog, Ui_GPUOptions): 
     
    106111                del os.environ["SAS_OPENCL"] 
    107112        # Sasmodels kernelcl doesn't exist when initiated with None 
    108         if 'sasmodels.kernelcl' in sys.modules: 
    109             sasmodels.kernelcl.ENV = None 
    110         from importlib import reload # assumed Python > 3.3 
    111         reload(sasmodels.core) 
     113        sasmodels.kernelcl.reset_environment() 
    112114        return no_opencl_msg 
    113115 
     
    123125 
    124126        try: 
    125             from sasmodels.kernelcl import environment 
    126             env = environment() 
     127            env = sasmodels.kernelcl.environment() 
    127128            clinfo = [(ctx.devices[0].platform.vendor, 
    128129                       ctx.devices[0].platform.version, 
     
    131132                       ctx.devices[0].version) 
    132133                      for ctx in env.context] 
    133         except ImportError: 
     134        except Exception: 
    134135            clinfo = None 
    135136 
     
    222223    clinfo = [] 
    223224    cl_platforms = [] 
     225 
    224226    try: 
    225227        import pyopencl as cl 
    226         cl_platforms = cl.get_platforms() 
    227228    except ImportError: 
    228         print("pyopencl import failed. Using only CPU computations") 
    229     except cl.LogicError as e: 
    230         print(e.value) 
     229        cl = None 
     230 
     231    if cl is None: 
     232        logger.warn("Unable to import the pyopencl package.  It may not " 
     233                    "have been installed.  If you wish to use OpenCL, try " 
     234                    "running pip install --user pyopencl") 
     235    else: 
     236        try: 
     237            cl_platforms = cl.get_platforms() 
     238        except cl.LogicError as err: 
     239            logger.warn("Unable to fetch the OpenCL platforms.  This likely " 
     240                        "means that the opencl drivers for your system are " 
     241                        "not installed.") 
     242            logger.warn(err) 
    231243 
    232244    p_index = 0 
Note: See TracChangeset for help on using the changeset viewer.