Skip to content

Instantly share code, notes, and snippets.

View mikaelhg's full-sized avatar
🏠
Working from home

Mikael Gueck mikaelhg

🏠
Working from home
View GitHub Profile
@mikaelhg
mikaelhg / README.md
Last active April 7, 2021 12:54
Run a Finnish to English language translation model fully on your own computer, in minutes.

Run a Finnish to English language translation model fully on your own computer, in minutes.

Automatically downloads the 300 MB language model to your disk.

Install:

python -m venv venv
venv/bin/pip install torch transformers sentencepiece
@mikaelhg
mikaelhg / helsinki_maps.sh
Last active June 27, 2024 05:57
Generate static, Helsinki only map tiles from OpenStreetMap data
# Bounding box from http://norbertrenner.de/osm/bbox.html
HELSINKI_BBOX=24.577,60.079,25.228,60.335
# OpenStreetMap extract file from Geofabrik
wget https://download.geofabrik.de/europe/finland-latest.osm.pbf
# Cut the 500 MB Finland data file into a 34 MB Helsinki data file
# as this is much faster than using the import bbox.
osmconvert finland-latest.osm.pbf -b="$HELSINKI_BBOX" --out-pbf >helsinki.pbf
@mikaelhg
mikaelhg / UploadTestApplication.kt
Last active March 6, 2021 20:46
Spring multipart file upload test with TestRestTemplate and ByteArrayResource
package com.example.uploadtest
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.multipart.MultipartFile
@SpringBootApplication
@mikaelhg
mikaelhg / cleanup.sh
Created March 5, 2021 10:14
Clean up after NVidia driver update failure
ls /var/lib/initramfs-tools | sudo xargs -n1 /usr/lib/dkms/dkms_autoinstaller start
sudo update-initramfs -c -k all
@mikaelhg
mikaelhg / .bazelrc.user
Last active February 9, 2021 12:13
Tensorflow Java build scripts
# AWS P2 instance type has K80 GPUs, compute capability 3.7
# AWS P3 instance type has V100 GPUs, compute capability 7.0
build:cuda --action_env=TF_CUDA_COMPUTE_CAPABILITIES=3.7,7.0
build:cuda --action_env=TF_CUDA_VERSION=10
build:cuda --action_env=TF_CUDNN_VERSION=7
# manually installed CUDA and cuDNN
build:cuda --action_env=TF_CUDA_PATHS=/usr/local/cuda-10.2.89,/usr/local/cudnn-10.2-7.6.5.32
@mikaelhg
mikaelhg / README.md
Created July 10, 2020 13:40
Using Packer to provision Amazon Linux 2 without seed.iso

(I also reported this to AWS: awsdocs/amazon-ec2-user-guide#123)

The "Running Amazon Linux 2 as a virtual machine onpremises" page describes a fairly cumbersome way of running Amazon Linux 2 in local virtual machines through using various tools to provision ISO9660 seed.iso files just to serve the VM instance two small data files.

It would be great it the documentation also pointed out that since the VM provisioning is being done with cloud-init, and the image has configured a fairly extensive datasource_list: [ NoCloud, AltCloud, ConfigDrive, OVF, None ] which starts with NoCloud, that NoCloud also allows you to serve these files over HTTP.

There are two easy ways of using network configuration instead of seed.iso. Either you tell GRUB to add a parameter to the kernel boot configuration, or you tell KVM/VMWare/Virtualbox to set the virtual machine's SMBIOS value to something which cloud-init's NoCloud understands.

The documentation page https://cloudinit.readthedocs.

@mikaelhg
mikaelhg / cuda-install.md
Last active May 21, 2024 07:48
Proper CUDA and cuDNN installation
date title tags
2020-02-29
Proper CUDA and cuDNN installation
tech

You're here, so you're probably already hurting because of CUDA and cuDNN compatibility, and I won't have to motivate you, or explain why you'd want to have standalone CUDA and cuDNN installations, if you're going to develop using Tensorflow in the long term.

1. Download your CUDA runfile (local) packages

@mikaelhg
mikaelhg / nvidia-resume
Created May 5, 2020 15:58
Ubuntu 20.04 suspend / sleep / wakeup NVidia CUDA / NVENC / NVDEC error
#! /bin/sh
# Workaround for broken CUDA/NVENC/NVDEC after suspend.
# This file now lives in /lib/systemd/system-sleep/nvidia-resume .
# Remember to chmod 755 it.
PATH=/sbin:/usr/sbin:/bin:/usr/bin
case $1 in
post)