我在配备GeForce GT 750M的Macbook Pro上安装了tensorflow 1.0.1 GPU版本.还安装了CUDA 8.0.71和cuDNN 5.1.我运行的tf代码可以很好地处理非CPU张量流,但是在GPU版本上,我得到了这个错误(曾经有一段时间它也有效):
name: GeForce GT 750M
major: 3 minor: 0 memoryClockRate (GHz) 0.9255
pciBusID 0000:01:00.0
Total memory: 2.00GiB
Free memory: 67.48MiB
I tensorflow/core/common_runtime/gpu/gpu_device.cc:906] DMA: 0
I tensorflow/core/common_runtime/gpu/gpu_device.cc:916] 0: Y
I tensorflow/core/common_runtime/gpu/gpu_device.cc:975] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GT 750M, pci bus id: 0000:01:00.0)
E tensorflow/stream_executor/cuda/cuda_driver.cc:1002] failed to allocate 67.48M (70754304 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY
Training...
E tensorflow/stream_executor/cuda/cuda_dnn.cc:397] could not create cudnn handle: CUDNN_STATUS_INTERNAL_ERROR
E tensorflow/stream_executor/cuda/cuda_dnn.cc:364] could not destroy cudnn handle: CUDNN_STATUS_BAD_PARAM …Run Code Online (Sandbox Code Playgroud) 有人可以解释为什么这两个Java代码的行为有所不同吗?第一个正确计算位数,但第二个只显示1或0表示非零数字.我不明白发生了什么.
public static void printNumUnitBits(int n){
int num=0;
for(int i=0;i<32;i++){
int x=n&1;
num=num+x;
n=n>>>1;
}
System.out.println("Number of one bits:"+num);
}
public static void printNumUnitBits(int n){
int num=0;
for(int i=0;i<32;i++){
num=num+n&1;
n=n>>>1;
}
System.out.println("Number of one bits:"+num);
}
Run Code Online (Sandbox Code Playgroud)