Lab4 Instructions
- Train your neural network on your host machine.
- Use your trained weights to perform inference on DE1-SoC board.
- Completion of Lab 3 and familiarity with the DE1-SoC board.
- Lab 3 OpenCL kernel to program the board.
- Lab 3
capture_image.c
program to capture image.
Required files are in the path tests/Inference
.
- Open Jupyter notebook
TrainNN
and run all the cells. - This will save the weights for each layer in
.bin
files.
Print each layer output to help debug your C++ code.
- Capture the image using the Lab 3 code
capture_image.cc
and follow the steps. - Run
TestImage
notebook. This will print each layer’s output. This helps in debugging and implementing each layer in the network.
- Extract
de1_soc
folder from the resources file. - Setup OpenCL environment:
- Go to the directory
C:\intelFPGA\hld\
and typeinit_opencl.bat
in the command prompt.
- Go to the directory
- Copy the hardware folder to
a10_ref
folder in the path:C:\intelFPGA\hld\board\a10_ref\
- Replace the hardware folder, as we don’t have permissions to change environment variables on the host machine. If you’re working on your own system, instead of replacing the folder, set the environment variable
AOCL_BOARD_PACKAGE_ROOT
to your own directory.
- Copy the
tests
folder toa10_ref
folder in the path. - In the command prompt, type:
aoc -list-boards
- This should list all the boards. Delete any other directories that are not needed on the host machine.
- Launch Quartus Prime, open the project in the hardware directory named
top.qpf
, and perform “Compile and Synthesis” (only compile and synthesis, not the entire flow). - Now, copy the
.cl
file you wrote in Lab 3 to thetests
folder inde1-soc
in the following path:tests/Inference/device/
- Close the Quartus project and go to the
tests/Inference
directory. Then run the following command:aoc device/<your lab 3 .cl file> -o bin/<kernel name>.aocx -board=de1soc_sharedonly
- This will compile the
.aocx
file that uses the hardware project and your multiplication kernel.
- Connect the SD card that is flashed with the Linux image to the host machine using the card reader.
- Copy the
.aocx
file generated in the previous step to the SD card (Do not modify any files that are already present in the SD card). This copied file will be available in the DE1-SoC Linux path:/media/fat_partition
- Boot the DE1-SoC by inserting the SD card and set up the OpenCL environment as described earlier:
cd OpenCL/ source init_opencl.sh