Machine Learning in Elixir: Some remarks on chapter 8 version B2.0 and cuda

@seanmor5

Machine Learning in Elixir

Some remarks on chapter 8 version B2.0
seanmor5

page 177
It is already mentioned here:
:discard is forgotten, it must be Stream.chunk_every(batch_size,batch_size, :discard)
I discovered it after an hour or so. First I tried to form chunks that are a multiple of32.
So I have thrown some pictures away and made 1000 >> 960 and 750 >> 630 (page 178). Fortunately there is :discard

page 184
Already mentioned: Use Polaris.Optimizers.adam(learning_rate: 1.0e-4)

page 191:
github.com/onnx/tensorflow_onnx doesn’t exist (anymore).
Why “Exporting models from …”. Why not “Importing …”

page 193:
unk__613 is now unk__615
The link tfhub.def is changed to Find Pre-trained Models | Kaggle

Then for all who were wondering: Why don’t I see “EXLA.Backend<cuda:…” but always
“EXLA.Backend<host:…”
Install the cuda-toolkit (on developer.nvidia.com/cuda-toolkit)

Do not forget to put in your .bashrc!!!:
export PATH=/usr/local/cuda-12./bin${PATH:+:${PATH}}
export PATH=/usr/local/cuda-12.3/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-12.3/lib64
${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export XLA_TARGET=cuda120
export EXLA_TARGET=cuda

It did not work with my old graphics card (Geforce GT9600) so I had to buy a new graphics card. An RTX 360, not the most expensive. And it is working now! Everything goes 30-40% faster.

The sentence “export PATH=/usr/local/cuda-12./bin${PATH:+:${PATH}}” must be removed/

And the sentence “export LD_LIBRARY_PATH=/usr/local/cuda-12.3/lib64
${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}” should be one line.
I discovered that because I did “source .bashrc” and got an error.

Furthermore you can add to the cuda part the next script because you get the warning a numan node is missing.
I don’t know if it is necessesary, cause I don’t know what a numan node is, but anyway…


#!/bin/bash
if [[ “$EUID” -ne 0 ]]; then
echo “Please run as root.”
exit 1
fi
PCI_ID=$(lspci | grep “VGA compatible controller: NVIDIA Corporation” | cut -d’ ’ -f1)
PCI_ID=“0000:$PCI_ID”
FILE=/sys/bus/pci/devices/$PCI_ID/numa_node
echo Checking $FILE for NUMA connection status…
if [[ -f “$FILE” ]]; then
CURRENT_VAL=$(cat $FILE)
if [[ “$CURRENT_VAL” -eq -1 ]]; then
echo Setting connection value from -1 to 0.
echo 0 > $FILE
else
echo Current connection value of $CURRENT_VAL is not -1.
fi
else
echo $FILE does not exist to update.
exit 1
fi