You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
i run the following code from Hunse repository t end of this code
import nengo
import nengo_ocl
import numpy as np
os.environ['PYOPENCL_COMPILER_OUTPUT'] = '1'
from nengo_extras.data import load_cifar10
from nengo_extras.cuda_convnet import CudaConvnetNetwork, load_model_pickle
from nengo_extras.gui import image_display_function
(X_train, y_train), (X_test, y_test), label_names = load_cifar10(label_names=True)
X_train = X_train.reshape(-1, 3, 32, 32).astype('float32')
X_test = X_test.reshape(-1, 3, 32, 32).astype('float32')
n_classes = len(label_names)
# crop data
X_train = X_train[:, :, 4:-4, 4:-4]
X_test = X_test[:, :, 4:-4, 4:-4]
# subtract mean
data_mean = X_train.mean(axis=0)
X_train -= data_mean
X_test -= data_mean
# retrieve from https://figshare.com/s/49741f9e2d0d29f68871
cc_model = load_model_pickle('cifar10-lif-1628.pkl')
# --- Run model in Nengo
presentation_time = 0.2
model = nengo.Network()
with model:
u = nengo.Node(nengo.processes.PresentInput(X_test, presentation_time))
ccnet = CudaConvnetNetwork(cc_model, synapse=nengo.synapses.Alpha(0.005))
nengo.Connection(u, ccnet.input, synapse=None)
input_p = nengo.Probe(u)
output_p = nengo.Probe(ccnet.output)
# --- image display
image_shape = X_test.shape[1:]
display_f = image_display_function(image_shape, scale=1, offset=data_mean)
display_node = nengo.Node(display_f, size_in=u.size_out)
nengo.Connection(u, display_node, synapse=None)
# --- output spa display
vocab_names = [s.upper() for s in label_names]
print(vocab_names)
vocab_vectors = np.eye(len(vocab_names))
vocab = nengo.spa.Vocabulary(len(vocab_names))
for name, vector in zip(vocab_names, vocab_vectors):
vocab.add(name.decode('ascii'), vector)
config = nengo.Config(nengo.Ensemble)
config[nengo.Ensemble].neuron_type = nengo.Direct()
with config:
output = nengo.spa.State(len(vocab_names), subdimensions=10, vocab=vocab)
nengo.Connection(ccnet.output, output.input)
n_presentations = 100
if 0:
# run ANN in Theano
os.environ['THEANO_FLAGS'] = 'device=gpu,floatX=float32'
Q = ccnet.theano_compute(X_test[:n_presentations])
Z = np.argmax(Q, axis=-1) == y_test[:n_presentations]
print("ANN accuracy (%d examples): %0.4f" % (n_presentations, Z.mean()))
with nengo_ocl.Simulator(model) as sim:
sim.run(n_presentations * presentation_time)
nt = int(presentation_time / sim.dt)
blocks = sim.data[output_p].reshape(n_presentations, nt, n_classes)
choices = np.argmax(blocks[:, -20:, :].mean(axis=1), axis=1)
accuracy = (choices == y_test[:n_presentations]).mean()
print('Spiking accuracy (%d examples): %0.3f' % (n_presentations, accuracy))
The errors messages are given below which i dont know how to rectify please suggest any solution
[b'AIRPLANE', b'AUTOMOBILE', b'BIRD', b'CAT', b'DEER', b'DOG', b'FROG', b'HORSE', b'SHIP', b'TRUCK']
C:\Users\zaid-pc\Anaconda3.0\lib\site-packages\pyopencl\cffi_cl.py:1516: CompilerWarning: Built kernel retrieved from cache. Original from-source build had warnings:
Build on <pyopencl.Device 'Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz' on 'Intel(R) OpenCL' at 0x86f86c4> succeeded, but said:
Compilation started
Compilation done
Linking started
Linking done
Kernel <reset> was not vectorized
Done.
warn(text, CompilerWarning)
C:\Users\zaid-pc\Anaconda3.0\lib\site-packages\pyopencl\cffi_cl.py:1516: CompilerWarning: From-binary build succeeded, but resulted in non-empty logs:
Build on <pyopencl.Device 'Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz' on 'Intel(R) OpenCL' at 0x86f86c4> succeeded, but said:
Linking started
Linking done
Kernel <reset> was not vectorized
Done.
warn(text, CompilerWarning)
C:\Users\zaid-pc\Anaconda3.0\lib\site-packages\pyopencl\cffi_cl.py:1516: CompilerWarning: Built kernel retrieved from cache. Original from-source build had warnings:
Build on <pyopencl.Device 'Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz' on 'Intel(R) OpenCL' at 0x86f86c4> succeeded, but said:
Compilation started
Compilation done
Linking started
Linking done
Kernel <copy> was not vectorized
Done.
warn(text, CompilerWarning)
C:\Users\zaid-pc\Anaconda3.0\lib\site-packages\pyopencl\cffi_cl.py:1516: CompilerWarning: From-binary build succeeded, but resulted in non-empty logs:
Build on <pyopencl.Device 'Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz' on 'Intel(R) OpenCL' at 0x86f86c4> succeeded, but said:
Linking started
Linking done
Kernel <copy> was not vectorized
Done.
warn(text, CompilerWarning)
C:\Users\zaid-pc\Anaconda3.0\lib\site-packages\pyopencl\cffi_cl.py:1516: CompilerWarning: Built kernel retrieved from cache. Original from-source build had warnings:
Build on <pyopencl.Device 'Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz' on 'Intel(R) OpenCL' at 0x86f86c4> succeeded, but said:
Compilation started
Compilation done
Linking started
Linking done
Kernel <fn> was successfully vectorized
Done.
warn(text, CompilerWarning)
C:\Users\zaid-pc\Anaconda3.0\lib\site-packages\pyopencl\cffi_cl.py:1516: CompilerWarning: From-binary build succeeded, but resulted in non-empty logs:
Build on <pyopencl.Device 'Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz' on 'Intel(R) OpenCL' at 0x86f86c4> succeeded, but said:
Linking started
Linking done
Kernel <fn> was successfully vectorized
Done.
warn(text, CompilerWarning)
C:\Users\zaid-pc\Anaconda3.0\lib\site-packages\pyopencl\cffi_cl.py:1516: CompilerWarning: Built kernel retrieved from cache. Original from-source build had warnings:
Build on <pyopencl.Device 'Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz' on 'Intel(R) OpenCL' at 0x86f86c4> succeeded, but said:
Compilation started
Compilation done
Linking started
Linking done
Kernel <reduce> was not vectorized
Done.
warn(text, CompilerWarning)
C:\Users\zaid-pc\Anaconda3.0\lib\site-packages\pyopencl\cffi_cl.py:1516: CompilerWarning: From-binary build succeeded, but resulted in non-empty logs:
Build on <pyopencl.Device 'Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz' on 'Intel(R) OpenCL' at 0x86f86c4> succeeded, but said:
Linking started
Linking done
Kernel <reduce> was not vectorized
Done.
warn(text, CompilerWarning)
C:\Users\zaid-pc\Anaconda3.0\lib\site-packages\pyopencl\cffi_cl.py:1516: CompilerWarning: Built kernel retrieved from cache. Original from-source build had warnings:
Build on <pyopencl.Device 'Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz' on 'Intel(R) OpenCL' at 0x86f86c4> succeeded, but said:
Compilation started
Compilation done
Linking started
Linking done
Kernel <elementwise_inc> was not vectorized
Done.
warn(text, CompilerWarning)
C:\Users\zaid-pc\Anaconda3.0\lib\site-packages\pyopencl\cffi_cl.py:1516: CompilerWarning: From-binary build succeeded, but resulted in non-empty logs:
Build on <pyopencl.Device 'Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz' on 'Intel(R) OpenCL' at 0x86f86c4> succeeded, but said:
Linking started
Linking done
Kernel <elementwise_inc> was not vectorized
Done.
warn(text, CompilerWarning)
C:\Users\zaid-pc\Anaconda3.0\lib\site-packages\pyopencl\cffi_cl.py:1516: CompilerWarning: Built kernel retrieved from cache. Original from-source build had warnings:
Build on <pyopencl.Device 'Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz' on 'Intel(R) OpenCL' at 0x86f86c4> succeeded, but said:
Compilation started
Compilation done
Linking started
Linking done
Kernel <timeupdate> was successfully vectorized
Done.
warn(text, CompilerWarning)
C:\Users\zaid-pc\Anaconda3.0\lib\site-packages\pyopencl\cffi_cl.py:1516: CompilerWarning: From-binary build succeeded, but resulted in non-empty logs:
Build on <pyopencl.Device 'Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz' on 'Intel(R) OpenCL' at 0x86f86c4> succeeded, but said:
Linking started
Linking done
Kernel <timeupdate> was successfully vectorized
Done.
warn(text, CompilerWarning)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-2-ebe41d061ca0> in <module>()
81
82
---> 83 with nengo_ocl.Simulator(model) as sim:
84 sim.run(n_presentations * presentation_time)
85
~\Anaconda3.0\lib\site-packages\nengo_ocl\simulator.py in __init__(self, network, dt, seed, model, context, n_prealloc_probes, profiling, if_python_code, planner, progress_bar)
306 with Timer() as plans_timer:
307 for op_type, op_list in op_groups:
--> 308 plans.extend(self.plan_op_group(op_type, op_list))
309 plans.extend(self.plan_probes())
310
~\Anaconda3.0\lib\site-packages\nengo_ocl\simulator.py in plan_op_group(self, op_type, ops)
600
601 def plan_op_group(self, op_type, ops):
--> 602 return getattr(self, 'plan_' + op_type.__name__)(ops)
603
604 def plan_PreserveValue(self, ops): # LEGACY
~\Anaconda3.0\lib\site-packages\nengo_ocl\simulator.py in plan_SimProcess(self, all_ops)
930 python_ops.extend(ops)
931
--> 932 process_plans = [p for attr, ops in iteritems(plan_groups)
933 for p in getattr(self, attr)(ops)]
934 python_plans = [p for op in python_ops
~\Anaconda3.0\lib\site-packages\nengo_ocl\simulator.py in <listcomp>(.0)
931
932 process_plans = [p for attr, ops in iteritems(plan_groups)
--> 933 for p in getattr(self, attr)(ops)]
934 python_plans = [p for op in python_ops
935 for p in self._plan_python_process(op)]
~\Anaconda3.0\lib\site-packages\nengo_ocl\simulator.py in _plan_Conv2d(self, ops)
1024 plans.append(plan_conv2d(
1025 self.queue, X, Y, F, B, p.shape_in, p.shape_out,
-> 1026 kernel_shape, conv, p.padding, p.strides))
1027
1028 return plans
~\Anaconda3.0\lib\site-packages\nengo_ocl\clra_nonlinearities.py in plan_conv2d(queue, X, Y, filters, biases, shape_in, shape_out, kernel_shape, conv, padding, strides, tag, transposed)
1642
1643 full_args = (X.base_data, filters.data, biases.data, Y.base_data)
-> 1644 _fn = cl.Program(queue.context, text).build().conv2d
1645 _fn.set_args(*full_args)
1646
~\Anaconda3.0\lib\site-packages\pyopencl\__init__.py in build(self, options, devices, cache_dir)
460 self._context, self._source, options_bytes, devices,
461 cache_dir=cache_dir, include_path=include_path),
--> 462 options_bytes=options_bytes, source=self._source)
463
464 if was_cached:
~\Anaconda3.0\lib\site-packages\pyopencl\__init__.py in _build_and_catch_errors(self, build_func, options_bytes, source)
504 # Python 3.2 outputs the whole list of currently active exceptions
505 # This serves to remove one (redundant) level from that nesting.
--> 506 raise err
507
508 # }}}
You're building for a CPU. Nengo OCL has not been well tested for CPUs, since there are so many different kinds, and the performance increase over the reference Nengo simulator is minimal.
If you want to run on your CPU, I'd just use nengo.Simulator instead of nengo_ocl.Simulator. If you want to run things faster, then look into using your GPU with PyOpenCL.
i run the following code from Hunse repository t end of this code
The errors messages are given below which i dont know how to rectify please suggest any solution
RuntimeError: clBuildProgram failed: BUILD_PROGRAM_FAILURE -
_Build on <pyopencl.Device 'Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz' on 'Intel(R) OpenCL' at 0x86f86c4>:
Compilation started
:24:11: error: invalid operands to binary expression ('const __global float *' and 'double')
:25:11: error: invalid operands to binary expression ('__global float *' and 'double')
Compilation failed
(options: -I "c:\users\zaid-pc\anaconda3.0\lib\site-packages\pyopencl\cl")
(source saved as C:\Users\zaid-pc\AppData\Local\Temp\tmpx3vqw_gi.cl)_
The text was updated successfully, but these errors were encountered: