<jupyter_start><jupyter_text>Setup<jupyter_code>!nvidia-smi
# if you see K80 change the runtime until you see P4.
import pynvml

pynvml.nvmlInit()
handle = pynvml.nvmlDeviceGetHandleByIndex(0)
device_name = pynvml.nvmlDeviceGetName(handle)

if device_name not in [b'Tesla T4', b'Tesla P4']:
  raise Exception("""
    Unfortunately this instance does not have a T4 GPU.
    
    Please make sure you've configured Colab to request a GPU instance type.
    
    Sometimes Colab allocates a Tesla K80 instead of a T4. Resetting the instance.

    If you get a K80 GPU, try Runtime -> Reset all runtimes...
  """)
else:
  print('Woo! You got the right kind of GPU!', device_name)
# cuda version
!nvcc -V
# python version
!python -V; pip -V<jupyter_output>Python 3.6.9
pip 19.3.1 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)<jupyter_text>Install cuda- https://news.developer.nvidia.com/run-rapids-on-google-colab/<jupyter_code>%%capture
# Install RAPIDS
!git clone https://github.com/rapidsai/rapidsai-csp-utils.git

!bash rapidsai-csp-utils/colab/rapids-colab.sh 0.14

import sys, os

dist_package_index = sys.path.index('/usr/local/lib/python3.6/dist-packages')
sys.path = sys.path[:dist_package_index] + ['/usr/local/lib/python3.6/site-packages'] + sys.path[dist_package_index:]
sys.path
exec(open('rapidsai-csp-utils/colab/update_modules.py').read(), globals())<jupyter_output>Cloning into 'rapidsai-csp-utils'...
remote: Enumerating objects: 165, done.[K
remote: Counting objects: 100% (165/165), done.[K
remote: Compressing objects: 100% (160/160), done.[K
remote: Total 165 (delta 60), reused 20 (delta 4), pack-reused 0[K
Receiving objects: 100% (165/165), 48.48 KiB | 670.00 KiB/s, done.
Resolving deltas: 100% (60/60), done.
PLEASE READ
********************************************************************************************************
Changes:
1. Default stable version is now 0.14.  Nightly is now 0.15.  We have fixed the long conda install.  Hooray!
2. You can now declare your RAPIDSAI version as a CLI option and skip the user prompts (ex: '0.14' or '0.15', between 0.13 to 0.15, without the quotes): 
        "!bash rapidsai-csp-utils/colab/rapids-colab.sh <version/label>"
        Examples: '!bash rapidsai-csp-utils/colab/rapids-colab.sh 0.14', or '!bash rapidsai-csp-utils/colab/rapids-colab.sh stable', or '!bash rapidsai-csp-utils/colab/rapids-colab[...]<jupyter_text>cuDF<jupyter_code>import nvstrings, nvcategory, cudf
import io, requests
import seaborn as sns

df = sns.load_dataset('tips')
df.head()
# create gpu dataframe
gdf = cudf.DataFrame(df)
gdf['tip_percentage'] = gdf['tip']/gdf['total_bill']*100

# display average tip by dining party size
print(gdf.groupby('size')['tip_percentage'].mean())<jupyter_output>size
1    21.729202
2    16.571919
3    15.215685
4    14.594901
5    14.149549
6    15.622920
Name: tip_percentage, dtype: float64<jupyter_text>cuML debscan<jupyter_code>import cuml

# Create and populate a GPU DataFrame
df_float = cudf.DataFrame()
df_float['0'] = [1.0, 2.0, 5.0]
df_float['1'] = [4.0, 2.0, 1.0]
df_float['2'] = [4.0, 2.0, 1.0]

# Setup and fit clusters
dbscan_float = cuml.DBSCAN(eps=1.0, min_samples=1)
dbscan_float.fit(df_float)

print(dbscan_float.labels_)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16447569550596147, 'fraction_numerical': 0.058391929073677774, 'mean_word_length': 4.660899653979238, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 16, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '292490', 'license': 'Apache-2.0', 'n_tokens_mistral': 1363, 'n_tokens_neox': 1233, 'n_words': 306, 'path': 'a05_Rapids/cudf_gcolab/cudf_example_gcolab.ipynb', 'repo_name': 'mindis/Big_Data_Analysis', 'size': '3271'}