- Install cuda
- 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
defmodule Streamer do | |
def async(enum) do | |
Stream.resource( | |
#Start | |
fn -> | |
origin = self | |
spawn fn -> | |
for x <- enum do | |
send origin, {:elem, x} | |
end |
~/.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
# 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) |
# 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!") |
docker-compose.yml
file dodocker-compose up
import asyncio | |
class TaskPool(object): | |
def __init__(self, workers): | |
self._semaphore = asyncio.Semaphore(workers) | |
self._tasks = set() | |
async def put(self, coro): |
using Base.Threads | |
using Distributions | |
using BenchmarkTools | |
ENV["PYCALL_JL_RUNTIME_PYTHON"] = Sys.which("python") | |
using PyCall | |
py""" | |
import sys |
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] |
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 |