Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions examples/aistore/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Run Hub on AIStore

Start a production-ready standalone docker of aistore. More information can be found [here](https://nvidia.github.io/aistore/deploy/prod/docker/single).
```sh
docker run \
-p 51080:51080 \
-v $(mktemp -d):/ais/disk0 \
aistore/cluster-minimal:latest
```

Run the script
```
python3 examples/aistore/simple.py
```
30 changes: 30 additions & 0 deletions examples/aistore/simple.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import hub
import numpy as np

creds = {'endpoint_url': 'http://localhost:51080/s3'}


def create_dataset(path: str):
""" Create hub dataset and upload random data """

ds = hub.empty(path, creds=creds, overwrite=True)
with ds:
ds.create_tensor("tensor")
for i in range(10):
ds.tensor.append(np.random.random((512, 512)))


def loop(path: str):
""" Load the dataset and stream to pytorch"""
ds = hub.load(path, creds)
dataloader = ds.pytorch()

for (x,) in dataloader:
print(x)


if __name__ == "__main__":
path = 's3://ubuntu/dataset'

create_dataset(path)
loop(path)