Skip to content

Instantly share code, notes, and snippets.

View cgarciae's full-sized avatar

Cristian Garcia cgarciae

View GitHub Profile
@cgarciae
cgarciae / async_stream.ex
Created February 13, 2016 19:31
Async Stream Colltaz Stream Elixir
defmodule Streamer do
def async(enum) do
Stream.resource(
#Start
fn ->
origin = self
spawn fn ->
for x <- enum do
send origin, {:elem, x}
end
@cgarciae
cgarciae / REAME.md
Last active April 19, 2018 01:26
cudnn-install-tensorflow

cudnn install ubuntu + tensorflow

  1. Install cuda
  2. Export variables in ~/.bashrc or ~/.zshrc.
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_HOME=/usr/local/cuda
  1. Download cudnn. Note: check TensorFlow install guide for the correct version.
  2. Extract cudnn, this extracts a folder named cuda, cd into it.
@cgarciae
cgarciae / client-async-as-completed.py
Last active September 23, 2018 15:21
client-async-as-completed.py
# client-async-as-completed.py
from aiohttp import ClientSession, TCPConnector
import asyncio
from itertools import islice
import sys
def limited_as_completed(coros, limit):
futures = [
asyncio.ensure_future(c)
@cgarciae
cgarciae / server.py
Last active September 23, 2018 15:22
server.py
# server.py
from aiohttp import web
import asyncio
import random
async def handle(request):
await asyncio.sleep(random.randint(0, 3))
return web.Response(text="Hello, World!")
@cgarciae
cgarciae / README.md
Created November 6, 2016 17:30
nvidia-docker + docker-compose hello world

nvidia-docker with docker-compose

Setup

  1. Install nvidia-docker-plugin
  2. Reboot (for some reason)
  3. On the folder with this docker-compose.yml file do
docker-compose up
@cgarciae
cgarciae / task_pool.py
Last active June 6, 2019 18:57
task_pool.py
import asyncio
class TaskPool(object):
def __init__(self, workers):
self._semaphore = asyncio.Semaphore(workers)
self._tasks = set()
async def put(self, coro):
@cgarciae
cgarciae / test.jl
Last active April 26, 2020 04:36
julia distance function + python imports
using Base.Threads
using Distributions
using BenchmarkTools
ENV["PYCALL_JL_RUNTIME_PYTHON"] = Sys.which("python")
using PyCall
py"""
import sys
@cgarciae
cgarciae / test.py
Last active April 26, 2020 14:46
python distance functions
import typing as tp
from jax import numpy as jnp
import jax
import numpy as np
import time
@jax.jit
def _distances_jax(data1, data2):
using Base.Threads
using LoopVectorization
using BenchmarkTools
const None = [CartesianIndex()]
function distances(data1, data2)
data1 = deg2rad.(data1)
data2 = deg2rad.(data2)
lat1 = @view data1[:, 1]
@cgarciae
cgarciae / tabular.py
Last active June 2, 2020 00:14
Tablular Attention
def get_model(params) -> tf.keras.Model:
x0 = tf.keras.Input(shape=(1,), name="x0")
x1 = tf.keras.Input(shape=(1,), name="x1")
inputs = [x0, x1]
# x0 embeddings