Comments (4)
This seems as a issue about memory leak in search case.
facebookresearch/faiss#2054
from faiss-rs.
@ava57r @Enet4 , it works.
Many thanks.
from faiss-rs.
Hello. Could you please provide a few examples that reproduce the problems reported? This would help to better understand the underlying issues with the bindings.
a. IndexImpl has not impl concurrentIndex, so IVFScalarQuantizerIndexImpl returned by into_ivf_scalar_quantizer builds error;
IndexImpl
should definitely not implement ConcurrentIndex
because it is unknown whether shared access to the index is safe. At best, there may be a poor integration of that with the IVF scalar quantizer.
from faiss-rs.
Sry for reply so late. @Enet4
Here is an example code. Mock as a server, its memory will raises rapidly from 2M to 10+G and without upper bound.
I build it with "rustc 1.58.0-nightly (b426445c6 2021-11-24)"οΌand faiss "c_api_v1.7.1" with "cmake -B build -DFAISS_ENABLE_C_API=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DFAISS_ENABLE_GPU=false" by "g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0".
extern crate faiss;
extern crate rand; //rand = "0.3.17"
fn random_embedding(rng: &mut ThreadRng, dims: usize) -> Vec<f32> {
let mut embedding = Vec::with_capacity(dims);
for _ in 0..dims {
embedding.push(rng.gen_range(-1.0, 1.0));
}
return embedding;
}
fn main() {
let mut rng = rand::thread_rng();
let dims = 64u32;
let doc_count = 10000usize;
{
let mut ids = Vec::with_capacity(doc_count);
let mut embeddings = Vec::with_capacity(doc_count * dims as usize);
for i in 0..doc_count {
ids.push(Idx::new(i as u64));
embeddings.extend_from_slice(random_embedding(&mut rng, dims as usize).as_slice());
}
let mut index =
IVFFlatIndexImpl::new_ip(faiss::FlatIndex::new_ip(dims).unwrap(), dims, 10).unwrap();
index.set_verbose(true);
index.train(&embeddings).unwrap();
index.add_with_ids(&embeddings, &ids).unwrap();
write_index(&index, "/tmp/test.index").unwrap();
}
loop {
let query = random_embedding(&mut rng, dims as usize);
let mut index = read_index("/tmp/test.index").unwrap();
let k = 100;
let mut count = 0;
loop {
if count > 10000 {
break;
}
let result = index.search(&query, k);
count += 1;
if count % 1000 == 0 {
println!("{} {:?}", count, result);
}
}
sleep(Duration::from_secs(10));
}
}
from faiss-rs.
Related Issues (20)
- Improve PreTransformIndex and update Clustering types HOT 1
- Macros to derive crate
- Support faiss_index_gpu_to_cpu in GpuIndexImpl HOT 2
- Use cxx for interop with Faiss HOT 1
- Slow training IVF indexes HOT 13
- Control over GPU <-> CPU result copies? HOT 1
- Update C-API v1.7.2 HOT 1
- Save and reopen Index after train()? HOT 1
- read_index io flag support HOT 3
- Undefined symbols for architecture arm64
- panicked at 'too large index value provided to Idx::new' HOT 4
- Write Index into memory or Read Index from memory HOT 1
- Does this crate plan to support generic IO? HOT 1
- Can you also add support for static libraries? HOT 6
- Updating to latest faiss? HOT 9
- Support for mac m1? HOT 7
- Support binary indexes HOT 5
- confusing build linker error HOT 2
- `&mut self` argument on `index.search` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from faiss-rs.