rocm e una calcolatrice con rete neurale

Circa sei mesi fa, per esigenze di gaming di mio figlio, ho deciso di cambiare la scheda video e già che c’ero ho pensato di comprarne una che sia supportata come acceleratore negli apprendimenti di machine learning tra cui keras.

Potevo scegliere una scheda Nvidia con cuda, come la precedente, ma ho optato per una scheda AMD per non avere tra i piedi driver proprietari. Dedicherò una riflessione su questo tipo di scelta, opensource vs proprietario. Le recenti recensione ne parlavano bene e sembrava che il driver rocm funzionasse bene out-of-the-box anche su Ubuntu. Nulla di più sbagliato, nemmeno la versione su docker, quella che doveva essere pronta all’uso, funzionava. Ci ho messo sei mesi per far sistemare tutto correttamente, ovviamente non a tempo pieno, solo nei ritagli di tempo e finalmente tutto funziona.

Step 1: Disinstallare tutti i driver video

sa nvidia con cuda che amd, facendo questo passo ho perso metà del sistema operativo perché tramite il meccanismo delle dipendenze ha disinstallato quasi tutto. Per la mia esperienza è l’unico modo per evitare di rimanere letteralmente incastrati con le dipendenze del driver AMD

Step2: Installazione dei driver AMD

Processo non è banale, o meglio lo è seguendo il processo indicato sul sito, ma rocm non funziona. Almeno per la mia scheda video “AMD Radeon RX 6650 XT”. Dopo l’installazione dell’installer dell’AMD ho modificato a mano i repository da cui scarica i pacchetti, dalla versione 5.7.2 alla versione 6.0.0 “deb https://repo.radeon.com/amdgpu/6.0/ubuntu jammy main”. Le altre versioni non si agganciavano a Keras/tensorflow

Step 3: Installazione di tensorflow

Trovare il giuso match è stata la cosa più complicata. Tensorflow va installato compatibile con la versione rocm presente. Anche qui ho dovuto disinstallare tutte le precedenti versioni e, non so come mai, avevo una libreria pip installata come root, che ovviamente mi ha dato problemi. Anche quella rimossa. La libreria Pythn da installare è tensorflow-rocm 2.13.1.600. Il numero finale 600 indica la versione del driver rocm (600=rocm-6.0.0). L’ultima versione 2.14.0.600 di tensorflow non va con la mia scheda.

Step 4: Configurazione

Siamo alla fine. Il mio è una scheda 6650 con deviceid gfx1032, rocm riconosce solo la scheda 6600 con deviceid gfx1030, quindi è stato necessario forzare il device id. Si può fare o con le variabili d’ambiente o direttamente in pyton con “os.environ[‘HSA_OVERRIDE_GFX_VERSION’] = ‘10.3.0’”, anche qui 10.3.0 indica la versione che corrisponde a gfx1030.

Finalmente la calcolatrice

Per provare ho usato una semplice calcolatrice, ma prima imposto l variabile e verifico che tutto si carichi correttamente

import os
import tensorflow as tf
from tensorflow.python.client import device_lib

os.environ['HSA_OVERRIDE_GFX_VERSION'] = '10.3.0'
print(f'tensorflow version: {tf.version.VERSION}')

tf.config.list_physical_devices('GPU')
device_lib.list_local_devices()

Il risultato mostra i dispositivi che tensorflow può utilizzare e quindi:

name: "/device:CPU:0"

name: "/device:GPU:0"

Ora il codice della calcolatrice:

import numpy as np
import tensorflow as tf
from tensorflow import keras
import time
start_time = time.time()
with tf.device('gpu:0'):
# Genera dati di training
input_data = np.random.rand(50000, 2)
target_data = np.sum(input_data, axis=1)
# Creo un modello semplice
model = keras.Sequential([
    keras.layers.Dense(20, activation='relu', input_shape=(2,)),
    keras.layers.Dense(20, activation='relu'),
    keras.layers.Dense(1)
])

# Compila il modello
model.compile(optimizer='adam', loss='mean_squared_error')

# Addestra il modello
model.fit(input_data, target_data, epochs=5)

Infine faccio un po’ di somme

# Testa il modello con nuovi dati
test_data = np.array([[0.3, 0.7], [0.05, 0.10],[5, 10], [1.2, 2.3]])# Testa il modello con nuovi dati
predictions = model.predict(test_data)
# Stampa i risultati
for i, prediction in enumerate(predictions):
print(f"{test_data[i]} = {prediction[0]:.2f}")

1/1 [==============================] - 0s 28ms/step
[0.3 0.7] = 1.00
[0.05 0.1 ] = 0.15
[ 5. 10.] = 14.38
[1.2 2.3] = 3.50

Il risultato della calcolatrice non è preciso, come accde sui modelli di reti neurali su cui non è stato fatto tuning, ma serviva per testare la scheda video.

Effetti collaterali

La scheda video è montata sul mio hmetheater-TV come si usava negli anni 2000, monta 2 ricevitori sattelitari, 2 tuner per DVB e controller dei giochi perché viene usato anche come postazione gaming e un device touch per rendere il monitor TV touchscreen. Usare la scheda video per tensorflow fa saltare i buffer video e la tv può essere vsta solo a a una risoluzione HD-rady di 1280×720…. Dedicherò una riflessione sulla scelta dell’opensource

Compilazione modulo TBS 6922 per scheda digitale

Compilazione TBS 6922

  1. download del media tree
  2. copia della cartella tbs/linux-tbs-drivers/linux/drivers/media/common/saa716x/ in media_build/linux/drivers/media/common/
  3. copia dei file tbs/linux-tbs-drivers/linux/drivers/media/dvb/frontend/tbs*.h il media_build/linux/drivers/media/dvb-frontend/
  4. copia del file tbs/linux-tbs-drivers/linux/drivers/media/dvb/frontends/stv090x.h a media_build/linux/drivers/media/dvb-frontend/
  5. esecuzione di v4l/tbs-x86_r3.sh
  6. copia dei file tbs/linux-tbs-drivers/*.o a media_build/v4l/
  7. Patch per rimuovere errori di compilazione
  8. make

Phase 1 – Digital Dashboard upgrade

My Volvo is a V60 MY12 and comes with an analogue Dashboard. Just a few years after I bought my car as second hand car, a new model came out with a digital dashboard. At first I was proud of my analogue dashboard, but in the last years in fact it looked a little too old style. Looking at the old and new dashboard I noticed they had the same form and size. So googling around for a I while i discovered that the retrofit isn’t very complex. The two dashboards shared also the same connector with the car and almost the same pin layout. In fact the new digital Dashboard has two additional cables for a canbus connection.

I also found some mounting instructions (https://www.youtube.com/watch?v=nX03RHOQxNQ), possible issues and solutions. A company also provides software update (https://d5t5.com) for the TFT dashboard if something isn’t working correctly. I bought a used TFT dashbord from the USA, shipping expenses were very high. Following the instructions everything works fine. If you don’t connect the canbus many functions don’t work including power indicator and ecosystem indicator. After the installation and without any kind of software update almost everything works, the only two exceptions are the TPMS indicator and the fuel indicator. In particular the fuel indicators works the opposite way, this means the when the tank is empty the indicator shows full and when the tank is full the indicator shows empty. This also affects the remaining kilometre indicator, after filling the tank the car tells you to stop and fill the tank, when the tank is empty the call tell you you can run another 1.000 km. After about 800km in this situation I decided it was time to try a software update.

The software update is easy but has some tricky point, one is the decode of the CEM unit of the car, than you have to run the software with the old display installed, so the software can read the old settings, afterward you swap the display and run the software again. The second run updates the setting of the TFT unit, you also see that the display turns on and off several times. In my case the procedure ended with an error. As final result the fuel indicator worked fine the TPMS like was still on. Contacting the guys of D5T5 didn’t help much, they were very nice in their first answers, but from their point of view the procedure ended correctly so after the first answer they stopped to answer at all. To solve the TPMS issue i opened the display and put some black tape on the light below the black dash mask. Works fine.

To summarize, changing the analogue dashboard with the new TFT is pretty simple, requires 30-60 minutes depending on your skills. installing it without any software update works with two limitations: TPMS shows red light since the older car don’t have TPMS, fuel indicator works the wrong way. The software update procedure from VDASH (https://d5t5.com/sw/vdash.exe) is somehow buggy and there is a risk it doesn’t end correctly. The overall cost is of about 270 €, 70€ to buy a used TFT dashborad, 50 € for the shipping, 150 € for the software update.

Group-buy

Ho deciso di iniziare un nuovo progetto nel tempo libero. Si tratta di realizzare un sito pensato per agevolare i negozianti nella gestione degli ordini.

Non so quanto può prendere piede la mia iniziativa e credo che servirebbe un investimento superiore a quello che riesco a mettere in campo io.

L’idea è di consentire ai negozi di zona di ricevere ordini, anche collettivi come ad esempio ordini condominiali. Oltre a questo la possibilità di caricare un prorpio elenco prodotti con i prezzi.

Qualcosa di veramente semplice che semplifichi la gestione.

http://www.group-buy.it/

WP to LinkedIn Auto Publish Powered By : XYZScripts.com