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.cprogram to capture image.
Required files are in the path tests/Inference.
- Open Jupyter notebook
TrainNNand run all the cells. - This will save the weights for each layer in
.binfiles.
Print each layer output to help debug your C++ code.
- Capture the image using the Lab 3 code
capture_image.ccand follow the steps. - Run
TestImagenotebook. This will print each layer’s output. This helps in debugging and implementing each layer in the network.
- Extract
de1_socfolder from the resources file. - Setup OpenCL environment:
- Go to the directory
C:\intelFPGA\hld\and typeinit_opencl.batin the command prompt.
- Go to the directory
- Copy the hardware folder to
a10_reffolder 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_ROOTto your own directory.
- Copy the
testsfolder toa10_reffolder 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
.clfile you wrote in Lab 3 to thetestsfolder inde1-socin the following path:tests/Inference/device/
- Close the Quartus project and go to the
tests/Inferencedirectory. Then run the following command:aoc device/<your lab 3 .cl file> -o bin/<kernel name>.aocx -board=de1soc_sharedonly- This will compile the
.aocxfile 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
.aocxfile 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