Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save moaminsharifi/796170b6936f29184b9958e52f4bc865 to your computer and use it in GitHub Desktop.
Save moaminsharifi/796170b6936f29184b9958e52f4bc865 to your computer and use it in GitHub Desktop.
how to install h2o4gpu on colab and use colab gpu for Machine Learning algorithm
# How To Install h2o4gpu and Tpot in colab?
1. export some env variable
2. install linux packges
3. uninstall sklearn and install python packges
4. enjoy fast auto ML with gpu
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# How To Install h2o4gpu and Tpot in colab?\n",
"1. export some env variable\n",
"2. install linux packges\n",
"3. uninstall sklearn and install python packges\n",
"4. enjoy fast auto ML with gpu"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# export some env variable\n",
"!export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_HOME/lib64/:$CUDA_HOME/lib/:$CUDA_HOME/extras/CUPTI/lib64"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#install python packges\n",
"!sudo apt-get install libopenblas-dev pbzip2\n",
"!sudo apt-get -y install libcurl4-openssl-dev libssl-dev libxml2-dev"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# uninstall sklearn and install python packges\n",
"!pip uninstall sklearn\n",
"!pip install -U --force-reinstall ipykernel\n",
"!pip install parallel\n",
"!pip install --force-reinstall -I h2o4gpu\n",
"!pip install TPOT"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## not need to reset your runtime"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# enjoy it\n",
"from tpot import TPOTClassifier\n",
"from h2o4gpu.datasets import load_iris\n",
"from h2o4gpu.model_selection import train_test_split\n",
"import numpy as np\n",
"\n",
"iris = load_iris()\n",
"X_train, X_test, y_train, y_test = train_test_split(iris.data.astype(np.float64),\n",
" iris.target.astype(np.float64), train_size=0.75, test_size=0.25, random_state=42)\n",
"\n",
"tpot = TPOTClassifier(generations=5, population_size=50, verbosity=2, random_state=42)\n",
"tpot.fit(X_train, y_train)\n",
"print(tpot.score(X_test, y_test))\n",
"tpot.export('tpot_iris_pipeline.py')"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
@mattiasu96
Copy link

I tried this solution but unfortunately it didn't work. Is it still viable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment