提交 766e8124 authored 作者: nouiz's avatar nouiz

Merge pull request #456 from delallea/minor

Minor fixes
import atexit, logging, os, shutil, stat, sys import atexit
import logging
import os
import shutil
import stat
import sys
import numpy import numpy
...@@ -179,7 +184,8 @@ if cuda_available: ...@@ -179,7 +184,8 @@ if cuda_available:
GpuAdvancedSubtensor1, GpuAdvancedIncSubtensor1, GpuAdvancedSubtensor1, GpuAdvancedIncSubtensor1,
GpuFlatten, GpuShape, GpuAlloc, GpuFlatten, GpuShape, GpuAlloc,
GpuJoin, fscalar, fvector, fmatrix, frow, fcol, GpuJoin, fscalar, fvector, fmatrix, frow, fcol,
ftensor3, ftensor4, scalar, vector, matrix, row, col, ftensor3, ftensor4,
scalar, vector, matrix, row, col,
tensor3, tensor4) tensor3, tensor4)
from basic_ops import host_from_gpu, gpu_from_host, as_cuda_array from basic_ops import host_from_gpu, gpu_from_host, as_cuda_array
import opt import opt
...@@ -198,15 +204,15 @@ def use(device, ...@@ -198,15 +204,15 @@ def use(device,
function is called. We need to be able to load this module only function is called. We need to be able to load this module only
to check if it is available! to check if it is available!
:param device: string "cpu", "gpu", "gpuN" N is the device number to use :param device: string "cpu", "gpu", "gpuN" (N is the device number to use)
:param force: Will always raise an exception if we can't use the gpu. :param force: Will always raise an exception if we can't use the gpu.
:param default_to_move_computation_to_gpu: If gpu init succeeded, enable by :param default_to_move_computation_to_gpu: If gpu init succeeded, enable by
default optimization to move default optimizations to move
computation to the gpu computations to the gpu
:param move_shared_float32_to_gpu: If gpu init succeeded, put new shared :param move_shared_float32_to_gpu: If gpu init succeeded, put new shared
variable in float32 on the gpu. variables in float32 on the gpu.
:param enable_cuda: If the gpu is correctly enabled, :param enable_cuda: If the gpu is correctly enabled,
set the the variable cuda_enabled to True. set the variable cuda_enabled to True.
""" """
global cuda_enabled, cuda_initialization_error_message global cuda_enabled, cuda_initialization_error_message
if force and not cuda_available and device.startswith('gpu'): if force and not cuda_available and device.startswith('gpu'):
...@@ -229,7 +235,8 @@ def use(device, ...@@ -229,7 +235,8 @@ def use(device,
error_addendum = "" error_addendum = ""
try: try:
if cuda_initialization_error_message: if cuda_initialization_error_message:
error_addendum = " (error: %s)" % cuda_initialization_error_message error_addendum = (" (error: %s)" %
cuda_initialization_error_message)
except NameError: except NameError:
# cuda_initialization_error_message is not available b/c compilation failed # cuda_initialization_error_message is not available b/c compilation failed
pass pass
......
...@@ -28,8 +28,8 @@ def test_nvidia_driver1(): ...@@ -28,8 +28,8 @@ def test_nvidia_driver1():
assert len(topo) == 2 assert len(topo) == 2
assert sum(isinstance(node.op, B.GpuSum) for node in topo) == 1 assert sum(isinstance(node.op, B.GpuSum) for node in topo) == 1
if not numpy.allclose(f(), a.sum()): if not numpy.allclose(f(), a.sum()):
raise Exception("The nvidia driver version installed with the OS " raise Exception("The nvidia driver version installed with this OS "
"don't give good result for reduction." "does not give good results for reduction."
"Installing the nvidia driver available on the same " "Installing the nvidia driver available on the same "
"download page as the cuda package will fix the " "download page as the cuda package will fix the "
"problem: http://developer.nvidia.com/cuda-downloads") "problem: http://developer.nvidia.com/cuda-downloads")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论