singa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <>
Subject [GitHub] [singa] chrishkchris commented on a change in pull request #728: Fix create_cuda_gpu
Date Wed, 10 Jun 2020 14:29:31 GMT

chrishkchris commented on a change in pull request #728:

File path: python/singa/
@@ -106,17 +106,21 @@ def create_cuda_gpus(num):
     return singa.Platform.CreateCudaGPUs(num)
-def create_cuda_gpu(set_default=False):
+Device.default_gpu_device = None

Review comment:
       When I change from `Device.default_gpu_device` to `default_gpu_device`
   default_gpu_device = None
   def create_cuda_gpu():
       '''Create a single CudaGPU device.
           a swig converted CudaGPU device.
       assert singa.USE_CUDA, 'SINGA has not been compiled with CUDA enabled.'
       if default_gpu_device is None:
           default_gpu_device = create_cuda_gpu_on(0)
       return default_gpu_device
   When I run the script `` to create device
   from singa import device
   if __name__ == '__main__':
   It returns:
   root@d05828f767ee:~/dcsysh/singa/examples/cnn# python3
   Traceback (most recent call last):
     File "", line 4, in <module>
     File "/root/dcsysh/singa/build/python/singa/", line 120, in create_cuda_gpu
       if default_gpu_device is None:
   UnboundLocalError: local variable 'default_gpu_device' referenced before assignment
   Seems if I don't store the variable `default_gpu_device` in a class, the variable `default_gpu_device`
is lost

This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:

View raw message