
Xc           @` s  d  d l  m Z m Z m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m Z d   Z	 e	   e
 Z e e j d  s e j j j j d k r?y" d  d l Z d  d l Z e Z Wqe e f k
 r e j d  qe j j k
 r;e j j r
  q<d e j k r&e j d =n  d  d l Z e Z qXn y d  d l Z e Z Wn e k
 rhn Xe re e j j d  re j j j   d  d l  Z  e  j! e j j j"  qe j d	  n  d S(
   i    (   t   absolute_importt   print_functiont   divisionN(   t   configc           C` s   t  j j d  rA t t  j  d k rA t j  j d t j d <nA t  j j d  r t t  j  d k r t j  j d t j d <n  d S(   sP   
    This set the GPU used by PyCUDA to the same as the one used by Theano.
    t   gpui   t   CUDA_DEVICEN(   R   t   devicet
   startswitht   lent   theanot   ost   environt   init_gpu_device(    (    (    s7   /tmp/pip-build-X4mzal/theano/theano/misc/pycuda_init.pyt   set_gpu_from_theano
   s
    't   cudas/   PyCUDA import failed in theano.misc.pycuda_initR   t   attachs>  For some unknow reason, theano.misc.pycuda_init was not imported before Theano initialized the GPU and your PyCUDA version is 2011.2.2 or earlier. To fix the problem, import theano.misc.pycuda_init manually before using/initializing the GPU, use the Theano flag pycuda.init=True or use a more recent version of PyCUDA.(#   t
   __future__R    R   R   R
   t   warningsR	   t   theano.sandbox.cudaR   R   t   Falset   pycuda_availablet   hasattrt   sandboxR   t   uset   device_numbert   Nonet   pycudat   pycuda.autoinitt   Truet   ImportErrort   RuntimeErrort   warnt   _drivert
   LogicErrort   force_deviceR   t   pycuda.drivert   drivert   ContextR   t   atexitt   registert   pop(    (    (    s7   /tmp/pip-build-X4mzal/theano/theano/misc/pycuda_init.pyt   <module>   sD   	

