# Workspace for loading Google vectors model using loadStaticModel

**URL:** <https://community.konduit.ai/t/workspace-for-loading-google-vectors-model-using-loadstaticmodel/203>\
**Category:** DL4J\
**Created:** [March 2, 2020, 3:48pm UTC](https://community.konduit.ai/t/workspace-for-loading-google-vectors-model-using-loadstaticmodel/203 "2020-03-02T15:48:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ethiel](https://avatars.discourse-cdn.com/v4/letter/e/df788c/32.png) [@ethiel](https://community.konduit.ai/u/ethiel)\
**Post date:** [March 2, 2020, 3:48pm UTC](https://community.konduit.ai/t/workspace-for-loading-google-vectors-model-using-loadstaticmodel/203/1 "2020-03-02T15:48:29Z")

</div>

Hi, people. I’m trying to load the google vectors model into DL4j, to use it later for sentiment analysis. I’m able to do it but with a big cost in RAM memory. I read about workspaces and how the memory is hold off-heap, so I tried to load it using loadStaticModel inside a workspace,just to see if my RAM consumption was lower. However, I’m not able to do it if I set my available amount of RAM to a number less of 3.4 GB (the size of Google vectors model). So, does it mean the workspaces are only for certain operations?. It’s that a bug? . the code is quite simple:

```
final WorkspaceConfiguration mmap = WorkspaceConfiguration.builder()
.initialSize(9500000000L)
.policyLocation(LocationPolicy.MMAP)
.policyAllocation(AllocationPolicy.STRICT)
.policyReset(ResetPolicy.ENDOFBUFFER_REACHED)
.tempFilePath("/Users/Downloads/temporalFile.temp")
.build();
final File wordVectorsFile = new File("/sentiment/GoogleNews-vectors-negative3002.bin");
try (final MemoryWorkspace ws = Nd4j.getWorkspaceManager().getAndActivateWorkspace(mmap, "M2")) {
final WordVectors wordVectors = WordVectorSerializer.loadStaticModel(wordVectorsFile);
} 

```

Any clues?.

---

<div class="post-metadata">

**Author:** ![raver119](https://avatars.discourse-cdn.com/v4/letter/r/9de053/32.png) [@raver119](https://community.konduit.ai/u/raver119)\
**Post date:** [March 2, 2020, 3:53pm UTC](https://community.konduit.ai/t/workspace-for-loading-google-vectors-model-using-loadstaticmodel/203/2 "2020-03-02T15:53:44Z")

</div>

Workspace in this case will be used for vectors only. But, obviously, won’t be used for, say, Strings in it. But ye, i’d expect it to work.

---

<div class="post-metadata">

**Author:** ![ethiel](https://avatars.discourse-cdn.com/v4/letter/e/df788c/32.png) [@ethiel](https://community.konduit.ai/u/ethiel)\
**Post date:** [March 2, 2020, 4:02pm UTC](https://community.konduit.ai/t/workspace-for-loading-google-vectors-model-using-loadstaticmodel/203/3 "2020-03-02T16:02:43Z")

</div>

Yes, I want to use it to load the vectors file only, outside JVM memory, and use it later. However, I can’t allocate vectors so process for loading the model fails. It shouldn’t be allocated to the workspace instead of RAM?.

---

<div class="post-metadata">

**Author:** ![raver119](https://avatars.discourse-cdn.com/v4/letter/r/9de053/32.png) [@raver119](https://community.konduit.ai/u/raver119)\
**Post date:** [March 2, 2020, 4:04pm UTC](https://community.konduit.ai/t/workspace-for-loading-google-vectors-model-using-loadstaticmodel/203/4 "2020-03-02T16:04:31Z")

</div>

File an issue please, and I’ll take a look. I’d definitely expect it to work that way.

---

<div class="post-metadata">

**Author:** ![ethiel](https://avatars.discourse-cdn.com/v4/letter/e/df788c/32.png) [@ethiel](https://community.konduit.ai/u/ethiel)\
**Post date:** [March 2, 2020, 7:06pm UTC](https://community.konduit.ai/t/workspace-for-loading-google-vectors-model-using-loadstaticmodel/203/5 "2020-03-02T19:06:06Z")

</div>

Done!.

> <https://github.com/eclipse/deeplearning4j/issues/8746>
>
> \#### Issue Description
> Workspace for loading Google vectors model using loadSta…ticModel does not load the model outside JVM memory. 
> 
> I’m trying to load the google vectors model into DL4j, to use it later. I’m able to do it but with a big cost in RAM memory. I read about workspaces and how the memory is hold off-heap, so I tried to load it using loadStaticModel inside a workspace, just to see if my RAM consumption was lower. However, I’m not able to do it if I set my available amount of RAM to a number less of 3.4 GB (the size of Google vectors model).
> So, does it mean the workspaces are there only for certain operations?.
> the code is quite simple:
> 
> final WorkspaceConfiguration mmap = WorkspaceConfiguration.builder()
> .initialSize(9500000000L)
> .policyLocation(LocationPolicy.MMAP)
> .policyAllocation(AllocationPolicy.STRICT)
> .policyReset(ResetPolicy.ENDOFBUFFER\_REACHED)
> .tempFilePath("/Users/Downloads/temporalFile.temp")
> .build();
> final File wordVectorsFile = new File("/sentiment/GoogleNews-vectors-negative3002.bin");
> try (final MemoryWorkspace ws = Nd4j.getWorkspaceManager().getAndActivateWorkspace(mmap, "M2")) {
> final WordVectors wordVectors = WordVectorSerializer.loadStaticModel(wordVectorsFile);
> } 
> \- expected behavior: 
> The memory consumption is lower and Google vectors model is loaded
> \- encountered behavior
> The process fails because vectors couldn't be allocated. 
> 
> \#### Version Information
> \* Deeplearning4j version: 1.0.0-beta6
> \* javacpp 1.5.2.
> \* Platform information (OS, etc): macOS Mojave or Unix System.
> 
> \#### Additional Information
> This is the stack trace. Numbers are random.
> Caused by: java.lang.OutOfMemoryError: Physical memory usage is too high: physicalBytes (2564) \> maxPhysicalBytes (1998) 
> 
> \#### Contributing
> I'm willing to help for fixing this issue, of course.

---

<div class="post-metadata">

**Author:** ![ethiel](https://avatars.discourse-cdn.com/v4/letter/e/df788c/32.png) [@ethiel](https://community.konduit.ai/u/ethiel)\
**Post date:** [March 2, 2020, 9:05pm UTC](https://community.konduit.ai/t/workspace-for-loading-google-vectors-model-using-loadstaticmodel/203/6 "2020-03-02T21:05:15Z")

</div>

This is a different question but related to solve the issue: How do I know that my workspace is actually storing my array?

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [March 3, 2020, 5:50pm UTC](https://community.konduit.ai/t/workspace-for-loading-google-vectors-model-using-loadstaticmodel/203/7 "2020-03-03T17:50:27Z")

</div>

Take a look inside the file and see what is inside. It should be the binary representation of the contents of the arrays inside that workspace.

---

<div class="post-metadata">

**Author:** ![ethiel](https://avatars.discourse-cdn.com/v4/letter/e/df788c/32.png) [@ethiel](https://community.konduit.ai/u/ethiel)\
**Post date:** [March 3, 2020, 6:01pm UTC](https://community.konduit.ai/t/workspace-for-loading-google-vectors-model-using-loadstaticmodel/203/8 "2020-03-03T18:01:04Z")

</div>

Oh, thanks. I did it and indeed, the workspace is used.However, is not used as much as I think it should be used, but that’s a different issue.
