Skip to content

Instantly share code, notes, and snippets.

View Kobzol's full-sized avatar

Jakub Beránek Kobzol

View GitHub Profile
@Kobzol
Kobzol / cartpole.py
Created December 4, 2023 17:16
CartPole (Deep) Q-learning
import collections
import dataclasses
import random
from typing import Optional, Tuple
import cv2
import numpy as np
import numpy.random
import tensorflow as tf
from tqdm import tqdm
@Kobzol
Kobzol / tf-installation.md
Created July 23, 2020 17:51
Building Tensorflow 2.2 with Cuda 10.2, CuDNN 8 and TensorRT 7.1 from source

Bulding TF 2.2 with TensorRT 7.1 from source

This is a short tutorial for installing Tensorflow 2.2 with Cuda 10.2, CuDNN 8 and TensorRT 7.1 on Ubuntu 18.04 with Python 3.6 and GCC 7.5. It works on my machine as of 23. 07. 2020 :) However, if you're reading this, the guide is probably already outdated.

If you have the exact same specification as I do, you can try your luck with my prebuilt pip wheel: https://mega.nz/file/MAozBYhI#8Tp7W8t-X5sBuWCVEviTN5quQnNNwaVMv90OAnEvGD0

Recently I got hold of Nvidia Xavier NX, which has JetPack 4.4 with Tensorflow 2.2 and TensortRT 7.1. I wanted to have the same environment on my desktop/server, but sadly, Tensorflow does not support CUDA 10.2, TensorRT 7.1 and CuDNN 8 by default

#include <zmq.hpp>
#include <sys/epoll.h>
#include <iostream>
zmq_msg_t msg()
{
zmq_msg_t msg;
zmq_msg_init_size(&msg, 5);
std::memcpy(zmq_msg_data(&msg), "Hello", 5);
return msg;
@Kobzol
Kobzol / parse.py
Created December 2, 2019 14:12
Dask distributed packet parser
import msgpack
BYTES = []
def parse_messages(stream):
data = stream.read(8)
if len(data) < 8:
return []
chunk_count = int.from_bytes(data, "little", signed=False)
#include <zmq.hpp>
#include <sys/epoll.h>
#include <iostream>
int main()
{
void* ctx = zmq_ctx_new();
void* socket = zmq_socket(ctx, ZMQ_PUSH);
std::cerr << zmq_connect(socket, "tcp://127.0.0.1:5555") << std::endl;
str_hodnota = function(v, p)
{
sum(v * p);
}
rozptyl = function(v, p)
{
str_hodnota(v ** 2, p) - str_hodnota(v, p) ** 2
}
var_koeficient = function(v, p)
{
@Kobzol
Kobzol / nahodna_velicina.R
Last active March 1, 2017 22:21
PS - nahodna velicina
str_hodnota = function(v, p)
{
sum(v * p);
}
rozptyl = function(v, p)
{
str_hodnota(v ** 2, p) - str_hodnota(v, p) ** 2
}
var_koeficient = function(v, p)
{
@Kobzol
Kobzol / words.c
Created October 20, 2016 14:57
Generate word at a given index
void generate(int index, int wordSize, int alphabetSize, char* result, char base = 0)
{
for (int i = wordSize - 1; i >= 0; i--)
{
int toSkip = std::pow(alphabetSize, i);
char c = index / toSkip;
result[wordSize - i - 1] = base + c;
index = index % toSkip;
}
}
@Kobzol
Kobzol / wtf.cpp
Created October 10, 2016 21:57
wtf
#include <iostream>
class A
{
public:
void fn() & {
std::cout << "A" << std::endl;
}
void fn() && {
std::cout << "B" << std::endl;
template <typename T, unsigned int S>
void convolution(cv::Mat& original, cv::Mat& resultImg, T kernel[S][S])
{
original.copyTo(resultImg);
int offset = S / 2;
T scale = 0;
for (int i = 0; i < S; i++)
{
for (int j = 0; j < S; j++)