jaromiru / AI-blog

Accompanying repository for Let's make a DQN / A3C series.
https://jaromiru.com
MIT License
392 stars 173 forks source link

Error in Seaquest-DDQN-PER.py #1

Closed hfarazi closed 7 years ago

hfarazi commented 7 years ago

Hi, Although I can run other scripts, I get the following error when I attempt to run Seaquest-DDQN-PER.py (Using theano backend): Using Theano backend. Using gpu device 0: GeForce GT 730M (CNMeM is disabled, cuDNN 5103) /usr/local/lib/python2.7/dist-packages/theano/sandbox/cuda/__init__.py:600: UserWarning: Your cuDNN version is more recent than the one Theano officially supports. If you see any problems, try updating Theano or downgrading cuDNN to version 5. warnings.warn(warn) [2016-11-18 15:58:01,675] Making new env: Seaquest-v0 Traceback (most recent call last): File "run.py", line 261, in <module> agent = Agent(stateCnt, actionCnt) File "run.py", line 139, in __init__ self.brain = Brain(stateCnt, actionCnt) File "run.py", line 49, in __init__ self.model = self._createModel() File "run.py", line 59, in _createModel model.add(Dense(output_dim=512, activation='relu')) File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 312, in add output_tensor = layer(self.outputs[0]) File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 487, in __call__ self.build(input_shapes[0]) File "/usr/local/lib/python2.7/dist-packages/keras/layers/core.py", line 695, in build name='{}_W'.format(self.name)) File "/usr/local/lib/python2.7/dist-packages/keras/initializations.py", line 59, in glorot_uniform return uniform(shape, s, name=name) File "/usr/local/lib/python2.7/dist-packages/keras/initializations.py", line 32, in uniform return K.random_uniform_variable(shape, -scale, scale, name=name) File "/usr/local/lib/python2.7/dist-packages/keras/backend/theano_backend.py", line 140, in random_uniform_variable return variable(np.random.uniform(low=low, high=high, size=shape), File "mtrand.pyx", line 1565, in mtrand.RandomState.uniform (numpy/random/mtrand/mtrand.c:17319) OverflowError: Range exceeds valid bounds

using Tensorflow backend: Using TensorFlow backend. I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.so locally I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.so locally I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.so locally I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcuda.so.1 locally I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcurand.so locally [2016-11-18 15:57:31,713] Making new env: Seaquest-v0 I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:925] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero I tensorflow/core/common_runtime/gpu/gpu_init.cc:102] Found device 0 with properties: name: GeForce GT 730M major: 3 minor: 5 memoryClockRate (GHz) 0.758 pciBusID 0000:01:00.0 Total memory: 1023.88MiB Free memory: 161.57MiB I tensorflow/core/common_runtime/gpu/gpu_init.cc:126] DMA: 0 I tensorflow/core/common_runtime/gpu/gpu_init.cc:136] 0: Y I tensorflow/core/common_runtime/gpu/gpu_device.cc:838] Creating TensorFlow device (/gpu:0) -> (device: 0, name: GeForce GT 730M, pci bus id: 0000:01:00.0) E tensorflow/stream_executor/cuda/cuda_driver.cc:965] failed to allocate 161.57M (169422848 bytes) from device: CUDA_ERROR_OUT_OF_MEMORY Traceback (most recent call last): File "run.py", line 260, in <module> agent = Agent(stateCnt, actionCnt) File "run.py", line 138, in __init__ self.brain = Brain(stateCnt, actionCnt) File "run.py", line 48, in __init__ self.model = self._createModel() File "run.py", line 54, in _createModel model.add(Convolution2D(32, 8, 8, subsample=(4,4), activation='relu', input_shape=(self.stateCnt))) File "/usr/local/lib/python2.7/dist-packages/keras/models.py", line 280, in add layer.create_input_layer(batch_input_shape, input_dtype) File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 370, in create_input_layer self(x) File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 514, in __call__ self.add_inbound_node(inbound_layers, node_indices, tensor_indices) File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 572, in add_inbound_node Node.create_node(self, inbound_layers, node_indices, tensor_indices) File "/usr/local/lib/python2.7/dist-packages/keras/engine/topology.py", line 149, in create_node output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0])) File "/usr/local/lib/python2.7/dist-packages/keras/layers/convolutional.py", line 466, in call filter_shape=self.W_shape) File "/usr/local/lib/python2.7/dist-packages/keras/backend/tensorflow_backend.py", line 1639, in conv2d x = tf.nn.conv2d(x, kernel, strides, padding=padding) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_nn_ops.py", line 394, in conv2d data_format=data_format, name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 703, in apply_op op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2319, in create_op set_shapes_for_outputs(ret) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1711, in set_shapes_for_outputs shapes = shape_func(op) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/common_shapes.py", line 246, in conv2d_shape padding) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/common_shapes.py", line 184, in get2d_conv_output_size (row_stride, col_stride), padding_type) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/common_shapes.py", line 149, in get_conv_output_size "Filter: %r Input: %r" % (filter_size, input_size)) ValueError: Filter must not be larger than the input: Filter: (8, 8) Input: (2, 84)

jaromiru commented 7 years ago

Hi,

the code uses Theano dimension ordering in the convolution layers, e.g. (32, 8, 8) as opposed to (8, 8, 32). Because of that, you have to make a small change to your ~/.keras/keras.json file. Change the corresponding line to:

    "image_dim_ordering": "th",

Hope that helps.